lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Woodward <a...@flax.co.uk>
Subject Re: Moving to Point, trouble with IntPoint.newRangeQuery()
Date Tue, 26 Sep 2017 11:48:17 GMT
The Points queries use a completely different data structure to the previous range queries,
so you can’t just use them interchangeably, you have to reindex your data.  I’m guessing
your ‘d1’ field here is a TrieIntField or similar?

Alan Woodward
www.flax.co.uk


> On 26 Sep 2017, at 12:22, Markus Jelsma <markus.jelsma@openindex.io> wrote:
> 
> Hello,
> 
> I have a QParser impl. that transforms text input to one or more integers, it makes a
BooleanQuery one a field with all integers in OR-more. It used to work by transforming the
integer using LegacyNumericUtils.intToPrefixCoded, getting a BytesRef.
> 
> I have now moved it to use IntPoint.newRangeQuery(field, integer, integer), i read (think
javadocs) this is the way to go, but i get no matches!
> 
>    Iterator<Integer> i = digests.iterator();
>    while (i.hasNext()) {
>      Integer digest = i.next();
>      queryBuilder.add(IntPoint.newRangeQuery(field, digest, digest), Occur.SHOULD);
>    }
>    return queryBuilder.build();
> 
> To be sure i didn't mess up elsewhere i also tried building a string for LuceneQParser
and cheat:
> 
>    Iterator<Integer> i = digests.iterator();
>    while (i.hasNext()) {
>      Integer digest = i.next();
>      str.append(ClientUtils.escapeQueryChars(digest.toString()));
>      if (i.hasNext()) {
>        str.append(" OR ");
>      }
>    }
>    QParser luceneQParser = new LuceneQParser(str.append(")").toString(), localParams,
params, req);
>    return luceneQParser.parse();
> 
> Well, this works! This is their respective debug output:
> 
> Using the IntPoint range query:
> 
> <result name="response" numFound="0" start="0">
> </result>
> <lst name="debug">
>  <str name="rawquerystring">{!q  f=d1}value</str>
>  <str name="querystring">{!q  f=d1}value</str>
>  <str name="parsedquery">(d1:[-1820898630 TO -1820898630])</str>
>  <str name="parsedquery_toString">d1:[-1820898630 TO -1820898630]</str>
> 
> LuceneQParser cheat, it does find!
> 
> <result name="response" numFound="2" start="0">
>  <doc>
>    <str name="id">1</str>
>    <int name="d1">-1820898630</int></doc>
> </result>
> <lst name="debug">
>  <str name="rawquerystring">{!qd f=d1}value</str>
>  <str name="querystring">{!qd f=d1}value</str>
>  <str name="parsedquery">d1:-1820898630</str>
> 
> There is not much difference in output, it looks fine, using LuceneQParser you can also
match using a range query, so what am i doing wrong?
> 
> Many thanks!
> Markus


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message