Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9968

Cannot use special characters in Suggester Context Query

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 6.0, 6.3
    • None
    • Suggester
    • None

    Description

      Reproduce

      1. Configure the Suggester to use a contextField, eg. context
      2. Add a document containing special characters in that field, eg. 'c#x'
      3. Use a context query with the Suggester, eg.

      suggest.cfq=context:c#x
      • Escaping the character makes no difference, eg.
        suggest.cfq=context:c\#x

      What happens

      The suggestions are not properly filtered

      What should happen

      The suggestions should be limited to documents where the field context is 'c#x'


      What happens is this:

      1. SolrSuggester.contextFilterQueryAnalyzer is hardwired to use StandardTokenizer
      2. The context query is parsed like this:

      SolrSuggester.parseContextFilterQuery
      query = new StandardQueryParser(contextFilterQueryAnalyzer).parse(contextFilter, CONTEXTS_FIELD_NAME);
      

      3. The StandardQueryParser together with StandardTokenizer will turn the context query into 'context:c context:x'
      4. This is used for filtering the suggestions
      5. Thus, the suggestion where context is 'c(x' is not returned

      Attached is an extension to SuggestComponentContextFilterQueryTest to reproduce this behavior.

      So, the question is, how to get the parser and tokenizer to use these special characters verbatim? Two ways I can think of:

      • Make contextFilterQueryAnalyzer configurable so KeywordTokenizer can be used
      • Use the analyzer defined for the context field in the schema

      Attachments

        Activity

          People

            Unassigned Unassigned
            gs Georg Sorst
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: