2017-09-09 6 views
0

私はこのプラグインを使用する方法を把握しようとしている私が欲しいようSolr hon-lucene-synonymsプラグインで他のフィールドを検索していますか?私が実行した場合</p> <p><a href="https://github.com/healthonnet/hon-lucene-synonyms" rel="nofollow noreferrer">https://github.com/healthonnet/hon-lucene-synonyms</a></p> <p>:

http://solr.example.com/solr/graphics/select/?q=royalty+free&debugQuery=on&defType=synonym_edismax&synonyms=true

それが動作し、私が取得しますデバッグは、私が望むことを実行していることを伝えます。

<arr name="expandedSynonyms"> 
<str>art</str> 
<str>cartoon</str> 
<str>clip</str> 
<str>clipart</str> 
<str>graphics</str> 
<str>image</str> 
<str>images</str> 
<str>multimedia</str> 
<str>picture</str> 
<str>pictures</str> 
<str>royalty free</str> 
</arr> 

+(((_text_:royalty) (_text_:free))^1.0 ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:cartoons _text_:clip _text_:clipart _text_:comic _text_:draw _text_:drawing _text_:drawings _text_:funny _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty _text_:sketch) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0) ((+((Synonym(_text_:art _text_:cartoon _text_:clip _text_:clipart _text_:graphics _text_:image _text_:images _text_:multimedia _text_:picture _text_:pictures _text_:royalty) _text_:free)))^1.0)) 
私はまた、より多くの他のフィルタを使用してダウン結果を絞り込むしたいとき

問題が来る:

http://solr.example.com/solr/graphics/select/?q=({のLucene%20sow =偽%20df =タイトル!}%の20royalty +無料)%20および20%( has_fla:1)& & debugQuery = & DEFTYPE = synonym_edismax &同義語=真

に私はちょうどこのデバッグを取得する:

<lst name="reasonForNotExpandingSynonyms"> 
<str name="name">HasComplexQueryOperators</str> 
<str name="explanation"> 
synonyms.ignoreQueryOperators is set to false, and this query contains complex query operators (e.g. AND, OR, *, -, etc.). Complex queries aren't supported. 
</str> 
</lst> 

確かに他のフィールドで検索する間に同義語の内容を維持する方法が必要ですか?私たちがしたいので、我々はこのプラグインを使用している理由は、ある - それは価値がある何のため

<queryParser name="synonym_edismax" class="com.github.healthonnet.search.SynonymExpandingExtendedDismaxQParserPlugin"> 
    <!-- You can define more than one synonym analyzer in the following list. 
     For example, you might have one set of synonyms for English, one for French, 
     one for Spanish, etc. 
     --> 
    <lst name="synonymAnalyzers"> 
     <!-- Name your analyzer something useful, e.g. "analyzer_en", "analyzer_fr", "analyzer_es", etc. 
      If you only have one, the name doesn't matter (hence "myCoolAnalyzer"). 
     --> 
     <lst name="myCoolAnalyzer"> 
     <!-- We recommend a PatternTokenizerFactory that tokenizes based on whitespace and quotes. 
      This seems to work best with most people's synonym files. 
      For details, read the discussion here: http://github.com/healthonnet/hon-lucene-synonyms/issues/26 
      --> 
     <lst name="tokenizer"> 
      <str name="class">solr.PatternTokenizerFactory</str> 
      <str name="pattern"><![CDATA[(?:\s|\")+]]></str> 
     </lst> 
     <!-- The ShingleFilterFactory outputs synonyms of multiple token lengths (e.g. unigrams, bigrams, trigrams, etc.). 
      The default here is to assume you don't have any synonyms longer than 4 tokens. 
      You can tweak this depending on what your synonyms look like. E.g. if you only have unigrams, you can remove 
      it entirely, and if your synonyms are up to 7 tokens in length, you should set the maxShingleSize to 7. 
      --> 
     <lst name="filter"> 
      <str name="class">solr.ShingleFilterFactory</str> 
      <str name="outputUnigramsIfNoShingles">true</str> 
      <str name="outputUnigrams">true</str> 
      <str name="minShingleSize">2</str> 
      <str name="maxShingleSize">4</str> 
     </lst> 
     <!-- This is where you set your synonym file. For the unit tests and "Getting Started" examples, we use example_synonym_file.txt. 
      This plugin will work best if you keep expand set to true and have all your synonyms comma-separated (rather than =>-separated). 
      --> 
     <lst name="filter"> 
      <str name="class">solr.SynonymFilterFactory</str> 
      <str name="tokenizerFactory">solr.KeywordTokenizerFactory</str> 
      <str name="synonyms">synonyms.txt</str> 
      <str name="expand">true</str> 
      <str name="ignoreCase">true</str> 
     </lst> 
     </lst> 
    </lst> 
    </queryParser> 

:私はQueryParsersolrconfig.xmlがどのように見えるさのSolr 6.6.0に

を使用しています標準セットアップ「王族」と「自由」と私たちが望むいけない同義語、2つの別々の単語として扱わで

royalty free, cartoon, images, photos 

次のような - 複数の単語の同義語を使用しています。

おかげ

答えて

1

いくつかのコメント:

& FQ = has_fla:あなただけのフィルタとして、それを追加した場合、確実に動作します: '1 has_fla' によってフィルタリング

  • だけでなく、それが望ましいです。フィルターはスコアリングには影響せず、後の照会のためにキャッシュされます。

  • このプラグインはSolr 5.3.1までのバージョンしか持っていないようですが、6.6でそれを使用しようとするとおそらく問題が発生します。単純なSolrで 'sow'と 'SynonymGraphFilter'を使用して複数の単語の同義語を使用できないことは確かですか?チェックthis

+0

お元気です!それはまさに私が必要なものです!私たちはsow = falseのアイデアを使用しようとしましたが、動作させることができませんでした(単に同義語の複数の単語を別々の単語として扱いたいと思っていました。とにかく、これはトリックをうまくやってくれると思います - ありがとう! –

+0

非常に助けてうれしい! – Persimmonium

関連する問題

 関連する問題