Search code examples
solrsolr-query-syntax

Stored fields in Solr are getting displayed in queries , why?


I am new to using Solr , and I have made a new core and copied the default schema.xml to the conf/ folder. The changes I have made is very trivial .

<field name="id" type="string" indexed="true" stored="false" required="true" multiValued="false" /> 

As you can see, I set the id field to stored=false. As per my understanding, the field id should not be displayed now when I do a query search. But that is not happening. I have tried restarting solr instance, and did the query to index the file again.

curl 'http://localhost:8983/solr/TwitterCore/update/json?commit=true' 
  --data-binary @$(echo TwitterData_Core_Conf/TwitterText_en_demo.json) 
  -H 'Content-type:application

As per Solr Wiki , this should have re-indexed my file. However when I run my query again, I still see the Id .

An example of the document returned (this is not the complete JSON node , I just copied some parts ) :

"text": [
      "RT @FollowTrainTV: Moonseternity just joined #FollowTrainTV - Watch them stream on http://t.co/oMcOGA51kT"
    ],
    "lang": [
      "en"
    ],
    "id": "0a8edfea-68f7-4b05-b370-27b5aba640b7", // I dont want to see this
    "_version_": 1512067627994841000

Maybe someone can give me detailed steps on re-indexing.


Solution

  • When you change the schema.xml file and restart the solr-server, the changes only apply for new documents. This means you have to clear the index and re-index all documents (Except at query tokenizer, these changes are active immediately after server restart, but this is not the case here). After re-indexing, the id field should not be visible any more.

    Another remark: You don't have to test your queries with curl. When you connect to http://localhost:8983/solr with your web-browser you should find an admin interface there. There you can select a core and test your queries.