Yoeri
Yoeri

Reputation: 1906

Solr web interface query with hyphen

I have a schema created by haystack for indexing books and authors in Solr 4.3 When performing a search, all works fine except for search-terms including a hyphen.

I know you must escape them by using a backslash but even with the solr web interface i am not able to find the correct docs.

As illustrated in the screenshots below, there is an author named Ukiyo-E which can be found by using full_name:(ukiyo). When entering full_name:(ukiyo-e) or full_name:(ukiyo-e), i can't find anything.

searching ukiyo gives one match Ukiyo-E

EDIT

Schema information:

<fieldType name="edge_ngram" class="solr.TextField" positionIncrementGap="1">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory" />
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front" />
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory" />
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
  </analyzer>
</fieldType>
...
<field name="full_name" type="edge_ngram" indexed="true" stored="true" multiValued="false" />

Analyser results: enter image description here

Upvotes: 0

Views: 740

Answers (1)

Artem Lukanin
Artem Lukanin

Reputation: 556

Analyze your term using the Analysis menu separately for indexing and querying. Specifically, you should have similar text processing routines during index and query time (see your full_name field in the schema). If you don't tokenize your query "ukiyo-e" into 2 terms ukiyo and e, but tokenize it during indexing, you will not be able to find the full term ukiyo-e.

Upvotes: 3

Related Questions