Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not finding any matches... am I being stupid? #78

Open
fatpeter55 opened this issue Sep 7, 2017 · 2 comments
Open

Not finding any matches... am I being stupid? #78

fatpeter55 opened this issue Sep 7, 2017 · 2 comments

Comments

@fatpeter55
Copy link

I'm trying to work out where I'm going wrong. I have:

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

...and in my synonyms.txt file I have:

cartoon, comic, cartoons, funny, drawing, sketch, draw, drawings, draw
clipart,image,art,graphics,clip,images,picture,pictures,multimedia,royalty free,royalty+free,cartoon

solrconfig.xml I have:

 <queryParser name="synonym_edismax" class="solr.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>

I've restarted Solr, but I still get this error:

<lst name="reasonForNotExpandingSynonyms">
  <str name="name">DidntFindAnySynonyms</str>
   <str name="explanation">No synonyms found for this query.  Check your synonyms file.</str>
 </lst>

I don't get it - what am I doing wrong?

@youradds
Copy link

youradds commented Sep 8, 2017

OK, well I found the problem - I need to do:

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

i.e pass in just the query (not field), as well as qf=title . However, this means I can't search on any other columns. Is there any way to do this? For example, we have a column called has_gif - I want to also narrow down the results further by only matching those.

Thanks

Andy

@clipartinc
Copy link

you sure the royalty+free is not causing the issue? Those special characters can cause issues in the synonym.txt file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants