On 4/14/2014 5:50 AM, Gurfan wrote: > We have a setup of SolrCloud 4.6. The fields Stored value is true. > Now I want to delete a field from indexed document. Is there any way from > which we can delete the field?? > Field which we are trying to delete(extracted from schema.xml): > > <field name="SField2" type="string" indexed="true" stored="true" > omitNorms="false" termVectors="false" /> > > We comment out this field(SField2) entry from schema.xml and reload/optimize > index from solr admin UI. > > Commit the solr index. > curl http://<<IP>>:8983/solr/update/json?commit=true > > Again fired query for the same but the removed field(SField2) is back > showing in query result.
I would guess based on your experience that the schema is only used at those moments that field analysis might be required. This means it is probably only used for two things: 1) Figuring out how to index a field when you do an update request, and 2) deciding whether a search field is allowed in a query and how to analyze the terms before the query is processed. When results are being determined for the response, it sounds like the schema is NOT consulted -- I think the code simply reads what's in the Lucene index and applies the "fl" parameter to decide which fields are returned. The index doesn't change when you change the schema -- Lucene does not use a schema. That's something Solr brings to the table. You'll need to reindex to remove this field from every document that currently contains it. http://wiki.apache.org/solr/HowToReindex > we tried another commands to delete the document ID: > > 1> For Deletion: > > curl http://localhost:8983/solr/update -H 'Content-type:application/json' -d > ' > [ > { > "delete":{ > "id":"c7d30e6850c54429b888794f7433e3c5" > } > } > ]' > > Output: {"responseHeader":{"status":400,"QTime":0},"error":{"msg":"Document > is missing mandatory uniqueKey field: id","code":400}} I can tell you that the "id" string in the above is *not* a field name. It refers to entries in the uniqueKey field, which your response seems to indicate actually is called "id". One difference that I noted is that you have the entire command surrounded by square brackets. The "multiple commands" section on the wiki shows curly braces. I would recommend removing the square brackets entirely -- you already have the curly braces. > 2> to set null in existing indexed field: > > curl http://localhost:8983/solr/update -H 'Content-type:application/json' -d > ' > [ > {"id" : "c7d30e6850c54429b888794f7433e3c5","SField2":{"set":null} } > ]' > > output: > {"responseHeader":{"status":500,"QTime":0},"error":{"msg":"For input string: > \"8888888888\"","trace":"java.lang.NumberFormatException: For input string: > \"8888888888\"\n\tat > java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) The value there is null ... and it's not surrounded by quotes. I don't know JSON very well, but I am pretty sure that this means JSON thinks it's a number, and that string cannot be parsed as a number. I don't think JSON understands null as a concept. Even if the atomic update request were to pass JSON parsing, the field no longer exists, so the index request would most likely fail. If your search code is not able to simply ignore a field in the response that it isn't using, then you'll have to reindex. Alternatively, you could use the fl parameter to limit the results to only certain fields. Thanks, Shawn