Can you delete a field from a document in Solr index?
Asked Answered
R

7

12

I have a big index, and during the indexation process there was an error. So to avoid reindexing which takes several days, I want to simply delete specific field and reindex. Is there any suggestion?

Raker answered 26/1, 2011 at 8:42 Comment(0)
A
5

You cannot. The solution would be to get the document, store temporarily in the memory, delete it, update the required field (remove, add) and then add the document back to the index.

Aviva answered 22/3, 2011 at 9:44 Comment(0)
B
10

If you're using Solr 4, you can use AtomicUpdate http://wiki.apache.org/solr/Atomic_Updates to remove a field much more easily. For example:

curl http://localhost:8983/solr/update?commit=true -H 'Content-type:application/json' --data-binary '[{"id": "630911fa-711a-3944-b1d2-cda6857f9827", "field_to_be_removed": {"set": null}}]'
Bis answered 30/10, 2013 at 17:48 Comment(1)
How can I remove certain field for all "id"? For e.g. this removes a certain field for id:630911fa-711a-3944-b1d2-cda6857f9827. But I want this all the id's.Sjoberg
W
7

you can do this if your rest of the fields are stored i.e stored="true ".as follows by setting null value.

<add>
  <doc>
    <!-- your unique key field -->
    <field name="employeeId">05991</field>  
    <!-- what ever field you want to delete -->
    <field name="skills" update="set" null="true" /> 
  </doc>
</add>

source:https://wiki.apache.org/solr/UpdateXmlMessages

Weigel answered 1/4, 2015 at 10:51 Comment(0)
A
5

You cannot. The solution would be to get the document, store temporarily in the memory, delete it, update the required field (remove, add) and then add the document back to the index.

Aviva answered 22/3, 2011 at 9:44 Comment(0)
L
4

You can delete the indexed document by it's id. If you want to change the schema by removing a field, then yes, you would have to reindex.

Lorient answered 26/1, 2011 at 15:51 Comment(1)
+1 or just avoid returning the field in the output format via fl parameter ;)Hellion
L
2

You can delete all the index using the command delete and a query like this:

java -Ddata=args -Dcommit=yes -jar post.jar "<delete><query>*:*</query></delete>"

Using the argument -Dcommit force to update the index, so, be careful not deleting all documents when you dont want.

Lateshalatest answered 29/11, 2011 at 11:57 Comment(1)
In the documentation of solr link explain how to delete one documents, but in the FAQ of solr explain deleting by query linkLateshalatest
O
1

With solr 8.11.2,

curl 'http://localhost:8983/solr/solr/schema' -d '{"delete-field":{"name":"${field_name}"}}'
Ophthalmic answered 10/7, 2022 at 13:48 Comment(0)
K
0

You can delete indexed value w.r.t. a field in Solr but not the field.

If you really want to delete a specific field while indexing then you should configure the field in schema.xml file before indexing document.

Kailyard answered 26/7, 2016 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.