Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 717 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Deleting solr documents from Solr Admin

#1
How do I delete all the documents in my SOLR index using the SOLR Admin.

I tried using the url and it works but want to know if the same can be done using the Admin..

Reply

#2


<!-- begin snippet: js hide: false -->

<!-- language: lang-html -->

curl

[To see links please register here]

-H "Content-type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl

[To see links please register here]

-H "Content-type: text/xml" --data-binary '<commit />'

<!-- end snippet -->

Reply

#3
Use one of the queries below in the *Document* tab of Solr Admin UI:

**XML:**

<delete><query>*:*</query></delete>

**JSON:**

{'delete': {'query': '*:*'}}

Make sure to select the `Document Type` drop down to `Solr Command (raw XML or JSON)`.
Reply

#4
Update: newer versions of Solr may work better with this answer:

[To see links please register here]


My original answer is below:

--------------------------------------------------------

I'm cheating a little, but not as much as writing the query by hand.

Since I've experienced the pain of accidental deletions before, I try to foolproof my deletions as much as possible (in any kind of data store).

1) Run a query in the Solr Admin Query screen, by only using the "q" parameter at the top left. Narrow it to the items you actually want to delete. For this example, I'm using `*:*`, but you can use things like `id:abcdef` or a range or whatever. If you have a crazy complex query, you may find it easier to do this multiple times, once for each part of the data you wish to delete.

2) On top of the results, there is a grayed out URL. If you hover the mouse over it, it turns black. This is the URL that was used to get the results. Right (context) click on it and open it in a new tab/window. You should get something like:

[To see links please register here]


Now, I want to get it into a delete format. I replace the `select?q=` with `update?commit=true&stream.body=<delete><query>` and, at the end, the `&wt=json&indent=true` with `</query></delete>`.

So I end up with:

[To see links please register here]

;

Take a deep breath, do whatever you do for good luck, and submit the url (enter key works).

Now, you should be able to go back to the Solr admin page and run the original query and get zero results.
Reply

#5
This solution is only applicable if you are deleting all the documents in multiple collections and not for selective deletion:

--------------------------------------------------------------------------------

I had the same scenario, where I needed to delete all the documents in multiple collections. There were close to 500k documents in each shard and there were multiple shards of each collection. Updating and deleting the documents using the query was a big task and thus followed the below process:

1. Used the Solr API for getting the details for all the collections -
```
http://<solrIP>:<port>/solr/admin/collections?action=clusterstatus&wt=json
```
This gives the details like name of collection, numShards, configname, router.field, maxShards, replicationFactor, etc.
2. Saved the output json with the above details in a file for future reference and took the backups of all the collections I needed to delete the documents in, using the following API:
```
http://<solr-ip>:<port>/solr/admin/collections?action=BACKUP&name=myBackupName&collection=myCollectionName&location=/path/to/my/shared/drive
```
3. Further I deleted all the collections which I need to remove all the documents for using the following:
```
http://<solr-ip>:<port>/solr/admin/collections?action=DELETEALIAS&name=collectionname
```
4. Re-created all the collections using the details in the Step 1 and the following API:
```
http://<solr-ip>:<port>/solr/admin/collections?action=CREATE&name=collectionname&numShards=number&replicationFactor=number&maxShardsPerNode=number&collection.configName=configname&router.field=routerfield
```

I executed the above steps in loop for all the collections and was done in seconds for around 100 collections with huge data. Plus, I had the backups as well for all the collections.

Refer to this for other Solr APIs: [DELETEALIAS: Delete a Collection Alias, *Input*](

[To see links please register here]

)
Reply

#6
select XML on collection Document tab and update below parameter.

`<delete><query>*:*</query></delete>`
Reply

#7
For everyone who doesn't like a lot of words :-)

[![Solr Admin: remove data from Core][1]][1]


[1]:
Reply

#8
If you want delete some documents by ID you can use the Solr POST tool.
```
./post -c $core_name ./delete.xml
```

Where the `delete.xml` file contains documents ids:
```
<delete>
<id>a3f04b50-5eea-4e26-a6ac-205397df7957</id>
</delete>
```

Reply

#9
Under the Documents tab, select "raw XML or JSON" under Document Type and just add the query you need using the unique identifiers for each document.

```json
{'delete': {'query': 'filter(product_id:(25634 25635 25636))'}}

```

[![enter image description here][1]][1]


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through