0

I am using Solr 8.6.1, started in solrcloud mode. The field type is

{
          "add-field-type" : {
              "name":"articleTitle",
              "positionIncrementGap":100,
              "multiValued":false,
              "class":"solr.TextField",
              "indexAnalyzer":{
                  "tokenizer":{ "class":"solr.StandardTokenizerFactory" },
                  "filters":[
                      { "class":"solr.LowerCaseFilterFactory" },
                      { "class":"solr.ManagedStopFilterFactory", "managed":"english" },
                      { "class":"solr.ManagedSynonymGraphFilterFactory", "managed":"english" },
                      { "class":"solr.FlattenGraphFilterFactory" },
                      { "class":"solr.PorterStemFilterFactory" }
                  ]
              },
              "queryAnalyzer":{
                  "tokenizer":{ "class":"solr.StandardTokenizerFactory" },
                  "filters":[
                      { "class":"solr.LowerCaseFilterFactory" },
                      { "class":"solr.ManagedStopFilterFactory", "managed":"english" },
                      { "class":"solr.ManagedSynonymGraphFilterFactory", "managed":"english" },
                      { "class":"solr.PorterStemFilterFactory" }
                  ]
              }
          }
      }

After I add a document

{
  "id": 100,
  "articleTitle": "Best smartphone"
} 

I update the synonyms list by API

curl -X PUT -H 'Content-type:application/json' --data-binary '["iphone", "smartphone"]' "http://localhost:8983/solr/articles/schema/analysis/synonyms/english"

and reload the collection by API

http://localhost:8983/solr/admin/collections?action=RELOAD&name=articles

However when I try to search the documents don't pop-up.

http://localhost:8983/solr/articles/select?q=articleTitle:iphone

No result are returned. I expected that added document will be returned.

It works only if I first update the synonyms list and after that add the document into collection.

How to configure Solr to find the documents by synonyms if the synonyms are changed after documents are created?

user13674325
  • 339
  • 2
  • 14
  • If you depend on the synonyms being expanded index time, then only re-indexing the document will change the tokens stored for that field. You'll have to add proper examples of what doesn't work - i.e. what content you're indexing and how you're querying it - what you expect the result to be and what it actually is. – MatsLindh Aug 26 '20 at 10:31
  • It will work for me if synonyms will be expanded at query time – user13674325 Aug 26 '20 at 10:44
  • Then you shouldn't have to re-add your document. Add proper examples about the issue - you can also use the "Analysis" page under Solr's admin to see exactly how your input text is being processed. – MatsLindh Aug 26 '20 at 10:49
  • @MatsLindh I've updated the question with examples – user13674325 Aug 26 '20 at 11:32
  • The analysis page should show you what expansion is taking place with your query; you should be able to see if the `smartphone` token is included - the graph part might also play a role. I don't have an environment right here to test with, but that should give you a good hint on where to continue – MatsLindh Aug 26 '20 at 12:45
  • If you are new to synonyms in Solr you might find this useful: https://library.brown.edu/DigitalTechnologies/using-synonyms-in-solr/ – Hector Correa Sep 01 '20 at 17:33

0 Answers0