Solr
  1. Solr
  2. SOLR-3350

TextField's parseFieldQuery method not using analyzer's enablePosIncr parameter

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.5, 4.0-ALPHA
    • Fix Version/s: None
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      parseFieldQuery method of TextField class just set

        ...
        boolean enablePositionIncrements = true;
        ...
      

      while that should be taken from Analyzer's configuration.
      The above condition is evaluated afterwards in two points:

        ...
        if (enablePositionIncrements) {
          mpq.add((Term[]) multiTerms.toArray(new Term[0]), position);
        } else {
          mpq.add((Term[]) multiTerms.toArray(new Term[0]));
        }
        return mpq;
        ...
        ...
        if (enablePositionIncrements) {
          position += positionIncrement;
          pq.add(new Term(field, term), position);
        } else {
           pq.add(new Term(field, term));
        }
        ...
      

        Activity

        Tommaso Teofili created issue -
        Hide
        Robert Muir added a comment -

        How can this be taken from the analyzers configuration?

        the Analyzer can use a mix of enablePositionIncrements=true or enablePositionIncrements=false
        for the different filters that support that option.

        Here is an example of a real use case (from text_ga):

        ...
        <!-- removes n-, etc. position increments is intentionally false! -->
        <filter class="solr.StopFilterFactory" ignoreCase="true" 
                words="lang/hyphenations_ga.txt"
                enablePositionIncrements="false"/>
        <filter class="solr.IrishLowerCaseFilterFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" 
                words="lang/stopwords_ga.txt" 
                enablePositionIncrements="true"/>
        ...
        
        Show
        Robert Muir added a comment - How can this be taken from the analyzers configuration? the Analyzer can use a mix of enablePositionIncrements=true or enablePositionIncrements=false for the different filters that support that option. Here is an example of a real use case (from text_ga): ... <!-- removes n-, etc. position increments is intentionally false! --> <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/hyphenations_ga.txt" enablePositionIncrements="false"/> <filter class="solr.IrishLowerCaseFilterFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_ga.txt" enablePositionIncrements="true"/> ...
        Hide
        Tommaso Teofili added a comment -

        Hi Robert,
        For TextField having enablePositionIncrements just set to true and then evaluating an always true condition seems just wrong (code wise) so we should discuss if the issue is either in the true constant or in the code switching on it.
        It should be clear how a mixed configuration like the one above should result in terms of an "overall" enablePositionIncrements property (true, false, not set) if that's needed in the field type implementation (maybe traversing objects from the QParser to the SchemaField or in some more convenient way, if it exists).
        Depending on the choice taken on how to fix the code, if a Solr type using TextField has a tokenizer/some filters with enablePositionIncrements set to false then there would be different options:

        • option 1: it should raise a configuration error
        • option 2: log a warning message
        • option 3: don't care (like it is now)
        Show
        Tommaso Teofili added a comment - Hi Robert, For TextField having enablePositionIncrements just set to true and then evaluating an always true condition seems just wrong (code wise) so we should discuss if the issue is either in the true constant or in the code switching on it. It should be clear how a mixed configuration like the one above should result in terms of an "overall" enablePositionIncrements property (true, false, not set) if that's needed in the field type implementation (maybe traversing objects from the QParser to the SchemaField or in some more convenient way, if it exists). Depending on the choice taken on how to fix the code, if a Solr type using TextField has a tokenizer/some filters with enablePositionIncrements set to false then there would be different options: option 1: it should raise a configuration error option 2: log a warning message option 3: don't care (like it is now)
        Hide
        Tommaso Teofili added a comment -

        for now I think we can at least remove the useless switches inside the code, as the broader discussion about "overall" enablePositionIncrements isn't trivial.

        Show
        Tommaso Teofili added a comment - for now I think we can at least remove the useless switches inside the code, as the broader discussion about "overall" enablePositionIncrements isn't trivial.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tommaso Teofili
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development