You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Dennis Gove <dp...@gmail.com> on 2017/01/02 21:33:23 UTC

MemoryIndex and query not matching a Long value

I'm messing around with a MemoryIndex and am indexing a field of type Long.
From everything I can tell, this should be added into a Document as type
org.apache.lucene.document.LongPoint. However, when I try to match it with
a query of form "a_i:1" it doesn't match.

For example, full document is
{
  a_s:"hello1",
  a_i:1
}
with Query object created from
"a_i:1"

the return in call to
index.search(query)

is 0 (ie, a non-match)

The only thing I can think of is that the document field should actually be
something else, or that the creation of a Query object from "a_i:1" isn't
going to match a LongPoint value.

Thanks!

Re: MemoryIndex and query not matching a Long value

Posted by Dennis Gove <dp...@gmail.com>.
I've found the problem. It appears the Analyzer I'm using is not
appropriate for numeric values. This results in a Query object of the wrong
type. Whereas when querying point values the type PointRangeQuery should be
used but a TermQuery is created instead. If I directly create a
PointRangeQuery with LongPoint.newExactQuery(....) then the expected
results are found.

// creates wrong Query object
Analyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser(null, analyzer);
queries.add(parser.parse("a_i:1"));

Now I need to figure out how I can turn an arbitrary lucene query (against
unknown field type) into a valid Query object for the field being queried
against. I think it'd be Ok to, in this case, determine the type of Query
based on the type of the search value...but I don't yet know if there's an
Analyzer that will do that, quasi-magically.

- Dennis

On Mon, Jan 2, 2017 at 5:01 PM, Dennis Gove <dp...@gmail.com> wrote:

> Thank you. This isn't a situation where I have access to a schema so I
> don't think I can make use of the FieldType methods. I'm implementing a
> Match stream as part of the streaming api (our discussion in
> https://issues.apache.org/jira/browse/SOLR-8530).
>
> An arbitrary tuple can come in with calculated values so the types of the
> values can't necessarily be determined from a schema. Due to this, I'm
> taking all fields in the tuple and constructing a document (see
> https://github.com/dennisgove/lucene-solr/blob/
> SolrMatch/solr/core/src/java/org/apache/solr/handler/
> LuceneMatchStream.java#L195).
>
> (side note: the working name is LuceneMatchStream because atm it only
> accepts Lucene syntax for the queries)
>
> - Dennis
>
>
> On Mon, Jan 2, 2017 at 4:45 PM, David Smiley <da...@gmail.com>
> wrote:
>
>> LongPoint uses the Points API.  If you are using a Solr QParserPlugin,
>> it's not going to use that API. Assuming you're in Solr land, I think you
>> should be using utility methods on FieldType (lookup from schema) which can
>> create the Field instances to be put on the document.
>>
>> ~ David
>>
>> > On Jan 2, 2017, at 4:33 PM, Dennis Gove <dp...@gmail.com> wrote:
>> >
>> > I'm messing around with a MemoryIndex and am indexing a field of type
>> Long. From everything I can tell, this should be added into a Document as
>> type org.apache.lucene.document.LongPoint. However, when I try to match
>> it with a query of form "a_i:1" it doesn't match.
>> >
>> > For example, full document is
>> > {
>> >   a_s:"hello1",
>> >   a_i:1
>> > }
>> > with Query object created from
>> > "a_i:1"
>> >
>> > the return in call to
>> > index.search(query)
>> >
>> > is 0 (ie, a non-match)
>> >
>> > The only thing I can think of is that the document field should
>> actually be something else, or that the creation of a Query object from
>> "a_i:1" isn't going to match a LongPoint value.
>> >
>> > Thanks!
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>

Re: MemoryIndex and query not matching a Long value

Posted by Dennis Gove <dp...@gmail.com>.
Thank you. This isn't a situation where I have access to a schema so I
don't think I can make use of the FieldType methods. I'm implementing a
Match stream as part of the streaming api (our discussion in
https://issues.apache.org/jira/browse/SOLR-8530).

An arbitrary tuple can come in with calculated values so the types of the
values can't necessarily be determined from a schema. Due to this, I'm
taking all fields in the tuple and constructing a document (see
https://github.com/dennisgove/lucene-solr/blob/SolrMatch/solr/core/src/java/org/apache/solr/handler/LuceneMatchStream.java#L195
).

(side note: the working name is LuceneMatchStream because atm it only
accepts Lucene syntax for the queries)

- Dennis


On Mon, Jan 2, 2017 at 4:45 PM, David Smiley <da...@gmail.com>
wrote:

> LongPoint uses the Points API.  If you are using a Solr QParserPlugin,
> it's not going to use that API. Assuming you're in Solr land, I think you
> should be using utility methods on FieldType (lookup from schema) which can
> create the Field instances to be put on the document.
>
> ~ David
>
> > On Jan 2, 2017, at 4:33 PM, Dennis Gove <dp...@gmail.com> wrote:
> >
> > I'm messing around with a MemoryIndex and am indexing a field of type
> Long. From everything I can tell, this should be added into a Document as
> type org.apache.lucene.document.LongPoint. However, when I try to match
> it with a query of form "a_i:1" it doesn't match.
> >
> > For example, full document is
> > {
> >   a_s:"hello1",
> >   a_i:1
> > }
> > with Query object created from
> > "a_i:1"
> >
> > the return in call to
> > index.search(query)
> >
> > is 0 (ie, a non-match)
> >
> > The only thing I can think of is that the document field should actually
> be something else, or that the creation of a Query object from "a_i:1"
> isn't going to match a LongPoint value.
> >
> > Thanks!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

Re: MemoryIndex and query not matching a Long value

Posted by David Smiley <da...@gmail.com>.
LongPoint uses the Points API.  If you are using a Solr QParserPlugin, it's not going to use that API. Assuming you're in Solr land, I think you should be using utility methods on FieldType (lookup from schema) which can create the Field instances to be put on the document.

~ David

> On Jan 2, 2017, at 4:33 PM, Dennis Gove <dp...@gmail.com> wrote:
> 
> I'm messing around with a MemoryIndex and am indexing a field of type Long. From everything I can tell, this should be added into a Document as type org.apache.lucene.document.LongPoint. However, when I try to match it with a query of form "a_i:1" it doesn't match.
> 
> For example, full document is
> {
>   a_s:"hello1",
>   a_i:1
> }
> with Query object created from
> "a_i:1"
> 
> the return in call to 
> index.search(query)
> 
> is 0 (ie, a non-match)
> 
> The only thing I can think of is that the document field should actually be something else, or that the creation of a Query object from "a_i:1" isn't going to match a LongPoint value.
> 
> Thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org