Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
196 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 Reply

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"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...