Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

synonym - "Is-a" relationship in Solr Synoyms

I have two texts:

Text-1

Our new Android Smartphone

Text-2

Our new iPhone Smartphone

I would like to tell Solr that "android" is a "smartphone".

Expected results:

If the user searches for "Android" only the first text should be found.

If the user searches for "Smartphone" both texts should be found.

If I use "equal synonyms" (SolrSynonymParser) (during indexing), then the term "Smartphone" would get expanded to "Smartphone, Android, iPhone" in both texts.

question from:https://stackoverflow.com/questions/66061943/is-a-relationship-in-solr-synoyms

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In addition to the comment of MatsLindh, to add an unidirectional synonym like: "android=>android,smartphone", you should also consider to add the Synonym Filter only at index time and not both at index and query time

For example:

<analyzer type="index"> 
   ...
   <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt"/>
   ... 
</analyzer>

This way, both "android" and "smartphone" will be indexed for any occurrence of "android"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...