Solr
  1. Solr
  2. SOLR-491

highlight doesn't work with range search

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.3
    • Fix Version/s: None
    • Component/s: highlighter
    • Labels:
      None
    • Environment:

      windows xp sp2 jboss4.0.5

      Description

      I need to do range search on an integer field, which is defined as type sint. It works fine without highlight. However if I turn on highlight, I got the following error:

      2008-02-25 16:54:53,524 ERROR [STDERR] Feb 25, 2008 4:54:53 PM org.apache.solr.core.SolrCore execute
      INFO: [xluo] /select/rows=10&start=0&hl.fl=bookCount&indent=on&q=bookCount:5&hl=true&version=2.2 0 0

      2008-02-25 16:54:53,524 ERROR [STDERR] Feb 25, 2008 4:54:53 PM org.apache.solr.common.SolrException log
      SEVERE: java.lang.NumberFormatException: For input string: " "
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Long.parseLong(Long.java:403)
      at java.lang.Long.parseLong(Long.java:461)
      at org.apache.solr.util.NumberUtils.long2sortableStr(NumberUtils.java:52)
      at org.apache.solr.schema.SortableLongField.toInternal(SortableLongField.java:49)
      at org.apache.solr.schema.FieldType$DefaultAnalyzer$1.next(FieldType.java:315)
      at org.apache.solr.highlight.TokenOrderingFilter.next(SolrHighlighter.java:439)
      at org.apache.lucene.search.highlight.Highlighter.getBestTextFragments(Highlighter.java:226)

      I also tried range strange on data field, got similr error too when use highlight. I posted the problem at solr user list, here is what Hoss said:
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      I'm not sure if i really understand what it would mean to highlight a numeric field, hilighting a range query probably won't ever work
      because of the way range queries are implemented in Solr ... but at the very least there should be a better error message in this case. (and the
      case of a simple single value numeric lookup should probably work)
      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      The reason I need to highlight the numeric or data field is I have to loop through the search result to apply role permission check on those fields. If the searcher doesn't have permission to see the numeric/date field of the user in the search result list, that field should be set to null when returned. If the search doesn't have permission on all matching fields, then the whole record should not be returned. How can I find out which field is the matching field if searching on multiple fields? The only easy way I can think about is if the field is highlighted, it's a matching field.

      http://www.mail-archive.com/solr-user@lucene.apache.org/msg09239.html

        Issue Links

          Activity

          Hide
          Otis Gospodnetic added a comment -

          Using a highlighter to determine which field(s) matched the query seems like the wrong thing to go. Maybe the highlighter brings you closer to having this information, but it feels like a hack to me.

          However, Xuesong, please try the patch in SOLR-553 and see if you can get by without getting the error. SOLR-553 makes use of LUCENE-794, which should handle ConstantScoreRangeQuery. If it does work for you, please close this issue or leave a comment and we'll close it. Thanks.

          Show
          Otis Gospodnetic added a comment - Using a highlighter to determine which field(s) matched the query seems like the wrong thing to go. Maybe the highlighter brings you closer to having this information, but it feels like a hack to me. However, Xuesong, please try the patch in SOLR-553 and see if you can get by without getting the error. SOLR-553 makes use of LUCENE-794 , which should handle ConstantScoreRangeQuery. If it does work for you, please close this issue or leave a comment and we'll close it. Thanks.
          Hide
          Mark Miller added a comment -

          No, it won't work. There is an option to highlight ConstantScoreRange, but by default it is not on. Looking though, there is a bug where I am not respecting that setting, so it is on But it really shouldn't be.

          So it could be turned on in solr, but it can bring problems, the most immediate being that you can't rewrite the query first - which means you can't highlight fuzzy/wildcard multiterm queries.

          • Mark
          Show
          Mark Miller added a comment - No, it won't work. There is an option to highlight ConstantScoreRange, but by default it is not on. Looking though, there is a bug where I am not respecting that setting, so it is on But it really shouldn't be. So it could be turned on in solr, but it can bring problems, the most immediate being that you can't rewrite the query first - which means you can't highlight fuzzy/wildcard multiterm queries. Mark
          Hide
          Koji Sekiguchi added a comment -

          This should be done at some point. Closing as duplicate.

          Show
          Koji Sekiguchi added a comment - This should be done at some point. Closing as duplicate.

            People

            • Assignee:
              Koji Sekiguchi
              Reporter:
              Xuesong Luo
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development