You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by John Seer <pu...@yahoo.com> on 2009/04/10 23:56:28 UTC

Sequential match query

Hello,
I have 3 terms and I want to much them in order I tried to use wildcard
query I am not getting any results back

Terms: A C F

Doc: name:A B C D E F

query: name:A*C*F

I am not getting any results back, 
Please any suggestions? 

Thanks for help in advance 
-- 
View this message in context: http://www.nabble.com/Sequential-match-query-tp22995240p22995240.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Sequential match query

Posted by Erick Erickson <er...@gmail.com>.
Wildcard queries are not lowercased, so depending upon
how you're indexing, that may be tripping you up.

See
http://wiki.apache.org/lucene-java/LuceneFAQ#head-133cf44dd3dff3680c96c1316a663e881eeac35a

Best
Erick

On Fri, Apr 10, 2009 at 2:56 PM, John Seer <pu...@yahoo.com> wrote:

>
> Hello,
> I have 3 terms and I want to much them in order I tried to use wildcard
> query I am not getting any results back
>
> Terms: A C F
>
> Doc: name:A B C D E F
>
> query: name:A*C*F
>
> I am not getting any results back,
> Please any suggestions?
>
> Thanks for help in advance
> --
> View this message in context:
> http://www.nabble.com/Sequential-match-query-tp22995240p22995240.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Sequential match query

Posted by Tim Williams <wi...@gmail.com>.
On Mon, Apr 13, 2009 at 2:18 PM, John Seer <pu...@yahoo.com> wrote:
>
> If I understand you guys correct
> If I have term which has n tokens I will need to create n SpanTermQuery put
> them in array and pass it to SpanNearQuery?

Can you post inline instead of top-posting?

What you have is essentially my suggestion, which, with your original
question looks like (with slop 2):

new SpanNearQuery
      (new SpanQuery[] {
        new SpanTermQuery(new Term("name", "A")),
        new SpanTermQuery(new Term("name", "C")),
        new SpanTermQuery(new Term("name", "F")) },
       2,
       true);

If you wanted to still use the QueryParser, Erik was suggesting you
could extend it and override "getFieldQuery" (there's a good example
of this in LIA I think) to, essentially, generate the query above.

--tim

> Erik Hatcher wrote:
>>
>>
>> On Apr 12, 2009, at 8:15 AM, Tim Williams wrote:
>>
>>> On Sun, Apr 12, 2009 at 5:56 AM, Erik Hatcher
>>> <er...@ehatchersolutions.com> wrote:
>>>>
>>>> On Apr 11, 2009, at 9:11 PM, Tim Williams wrote:
>>>>
>>>>> On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
>>>>> <er...@gmail.com> wrote:
>>>>>>
>>>>>> That'll teach me to scan a post. The link I sent you
>>>>>> is still relevant, but wildcards are NOT intended to be used to
>>>>>> concatenate terms. You want a phrase query or a span query
>>>>>> for that. i.e. "A C F"~# where # is the "slop", that is, the number
>>>>>> of other terms allowed to appear between your desired terms.
>>>>>>
>>>>>> SpanQueries are constructed programmatically, and PhraseQueries
>>>>>> are produced by the parser.
>>>>>
>>>>> As I understand it though, there's no way to use the queryparser to
>>>>> construct an *ordered* phrase query with slop (which is what I think
>>>>> he's after), right?  I gather that'd have to be done manually with a
>>>>> SpanNearQuery.  I'd love to hear that the query parser has syntax
>>>>> for
>>>>> this though...
>>>>
>>>> QueryParser does not create any SpanQuery's, but one can subclass
>>>> QueryParser and override getFieldQuery() to put in a SpanQuery
>>>> instead of a
>>>> PhraseQuery.
>>>
>>> Thanks Erik, wouldn't this be an all-or-nothing replacement though?
>>> In other words, by creating ordered SpanNearQuery's as the override,
>>> wouldn't he loose the current unordered PhraseQuery+slop
>>> functionality?  I haven't seen a way to subclass the QueryParser to
>>> support both (e.g. extend the syntax)?
>>
>> As always, it depends.  If the QueryParser subclass has a switch to
>> toggle between SpanNearQuery and PhraseQuery it could controlled by
>> the code which way to go.  But yeah, it's not currently possible to
>> extend the syntax of QueryParser with a subclass.  There is a nice new
>> open issue with a new query parser implementation that is vastly more
>> flexible - we'll see that come in to Lucene in the near future.
>>
>>       Erik
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Sequential-match-query-tp22995240p23026389.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


Re: Sequential match query

Posted by John Seer <pu...@yahoo.com>.
If I understand you guys correct
If I have term which has n tokens I will need to create n SpanTermQuery put
them in array and pass it to SpanNearQuery?



Erik Hatcher wrote:
> 
> 
> On Apr 12, 2009, at 8:15 AM, Tim Williams wrote:
> 
>> On Sun, Apr 12, 2009 at 5:56 AM, Erik Hatcher
>> <er...@ehatchersolutions.com> wrote:
>>>
>>> On Apr 11, 2009, at 9:11 PM, Tim Williams wrote:
>>>
>>>> On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
>>>> <er...@gmail.com> wrote:
>>>>>
>>>>> That'll teach me to scan a post. The link I sent you
>>>>> is still relevant, but wildcards are NOT intended to be used to
>>>>> concatenate terms. You want a phrase query or a span query
>>>>> for that. i.e. "A C F"~# where # is the "slop", that is, the number
>>>>> of other terms allowed to appear between your desired terms.
>>>>>
>>>>> SpanQueries are constructed programmatically, and PhraseQueries
>>>>> are produced by the parser.
>>>>
>>>> As I understand it though, there's no way to use the queryparser to
>>>> construct an *ordered* phrase query with slop (which is what I think
>>>> he's after), right?  I gather that'd have to be done manually with a
>>>> SpanNearQuery.  I'd love to hear that the query parser has syntax  
>>>> for
>>>> this though...
>>>
>>> QueryParser does not create any SpanQuery's, but one can subclass
>>> QueryParser and override getFieldQuery() to put in a SpanQuery  
>>> instead of a
>>> PhraseQuery.
>>
>> Thanks Erik, wouldn't this be an all-or-nothing replacement though?
>> In other words, by creating ordered SpanNearQuery's as the override,
>> wouldn't he loose the current unordered PhraseQuery+slop
>> functionality?  I haven't seen a way to subclass the QueryParser to
>> support both (e.g. extend the syntax)?
> 
> As always, it depends.  If the QueryParser subclass has a switch to  
> toggle between SpanNearQuery and PhraseQuery it could controlled by  
> the code which way to go.  But yeah, it's not currently possible to  
> extend the syntax of QueryParser with a subclass.  There is a nice new  
> open issue with a new query parser implementation that is vastly more  
> flexible - we'll see that come in to Lucene in the near future.
> 
> 	Erik
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sequential-match-query-tp22995240p23026389.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Sequential match query

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 12, 2009, at 8:15 AM, Tim Williams wrote:

> On Sun, Apr 12, 2009 at 5:56 AM, Erik Hatcher
> <er...@ehatchersolutions.com> wrote:
>>
>> On Apr 11, 2009, at 9:11 PM, Tim Williams wrote:
>>
>>> On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
>>> <er...@gmail.com> wrote:
>>>>
>>>> That'll teach me to scan a post. The link I sent you
>>>> is still relevant, but wildcards are NOT intended to be used to
>>>> concatenate terms. You want a phrase query or a span query
>>>> for that. i.e. "A C F"~# where # is the "slop", that is, the number
>>>> of other terms allowed to appear between your desired terms.
>>>>
>>>> SpanQueries are constructed programmatically, and PhraseQueries
>>>> are produced by the parser.
>>>
>>> As I understand it though, there's no way to use the queryparser to
>>> construct an *ordered* phrase query with slop (which is what I think
>>> he's after), right?  I gather that'd have to be done manually with a
>>> SpanNearQuery.  I'd love to hear that the query parser has syntax  
>>> for
>>> this though...
>>
>> QueryParser does not create any SpanQuery's, but one can subclass
>> QueryParser and override getFieldQuery() to put in a SpanQuery  
>> instead of a
>> PhraseQuery.
>
> Thanks Erik, wouldn't this be an all-or-nothing replacement though?
> In other words, by creating ordered SpanNearQuery's as the override,
> wouldn't he loose the current unordered PhraseQuery+slop
> functionality?  I haven't seen a way to subclass the QueryParser to
> support both (e.g. extend the syntax)?

As always, it depends.  If the QueryParser subclass has a switch to  
toggle between SpanNearQuery and PhraseQuery it could controlled by  
the code which way to go.  But yeah, it's not currently possible to  
extend the syntax of QueryParser with a subclass.  There is a nice new  
open issue with a new query parser implementation that is vastly more  
flexible - we'll see that come in to Lucene in the near future.

	Erik


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


Re: Sequential match query

Posted by Tim Williams <wi...@gmail.com>.
On Sun, Apr 12, 2009 at 5:56 AM, Erik Hatcher
<er...@ehatchersolutions.com> wrote:
>
> On Apr 11, 2009, at 9:11 PM, Tim Williams wrote:
>
>> On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
>> <er...@gmail.com> wrote:
>>>
>>> That'll teach me to scan a post. The link I sent you
>>> is still relevant, but wildcards are NOT intended to be used to
>>> concatenate terms. You want a phrase query or a span query
>>> for that. i.e. "A C F"~# where # is the "slop", that is, the number
>>> of other terms allowed to appear between your desired terms.
>>>
>>> SpanQueries are constructed programmatically, and PhraseQueries
>>> are produced by the parser.
>>
>> As I understand it though, there's no way to use the queryparser to
>> construct an *ordered* phrase query with slop (which is what I think
>> he's after), right?  I gather that'd have to be done manually with a
>> SpanNearQuery.  I'd love to hear that the query parser has syntax for
>> this though...
>
> QueryParser does not create any SpanQuery's, but one can subclass
> QueryParser and override getFieldQuery() to put in a SpanQuery instead of a
> PhraseQuery.

Thanks Erik, wouldn't this be an all-or-nothing replacement though?
In other words, by creating ordered SpanNearQuery's as the override,
wouldn't he loose the current unordered PhraseQuery+slop
functionality?  I haven't seen a way to subclass the QueryParser to
support both (e.g. extend the syntax)?

Thanks,
--tim

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


Re: Sequential match query

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Apr 11, 2009, at 9:11 PM, Tim Williams wrote:

> On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
> <er...@gmail.com> wrote:
>> That'll teach me to scan a post. The link I sent you
>> is still relevant, but wildcards are NOT intended to be used to
>> concatenate terms. You want a phrase query or a span query
>> for that. i.e. "A C F"~# where # is the "slop", that is, the number
>> of other terms allowed to appear between your desired terms.
>>
>> SpanQueries are constructed programmatically, and PhraseQueries
>> are produced by the parser.
>
> As I understand it though, there's no way to use the queryparser to
> construct an *ordered* phrase query with slop (which is what I think
> he's after), right?  I gather that'd have to be done manually with a
> SpanNearQuery.  I'd love to hear that the query parser has syntax for
> this though...

QueryParser does not create any SpanQuery's, but one can subclass  
QueryParser and override getFieldQuery() to put in a SpanQuery instead  
of a PhraseQuery.

	Erik


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


Re: Sequential match query

Posted by Tim Williams <wi...@gmail.com>.
On Sat, Apr 11, 2009 at 12:25 PM, Erick Erickson
<er...@gmail.com> wrote:
> That'll teach me to scan a post. The link I sent you
> is still relevant, but wildcards are NOT intended to be used to
> concatenate terms. You want a phrase query or a span query
> for that. i.e. "A C F"~# where # is the "slop", that is, the number
> of other terms allowed to appear between your desired terms.
>
> SpanQueries are constructed programmatically, and PhraseQueries
> are produced by the parser.

As I understand it though, there's no way to use the queryparser to
construct an *ordered* phrase query with slop (which is what I think
he's after), right?  I gather that'd have to be done manually with a
SpanNearQuery.  I'd love to hear that the query parser has syntax for
this though...

--tim

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


Re: Sequential match query

Posted by Erick Erickson <er...@gmail.com>.
That'll teach me to scan a post. The link I sent you
is still relevant, but wildcards are NOT intended to be used to
concatenate terms. You want a phrase query or a span query
for that. i.e. "A C F"~# where # is the "slop", that is, the number
of other terms allowed to appear between your desired terms.

SpanQueries are constructed programmatically, and PhraseQueries
are produced by the parser.

Best
Erick@IReadItThisTimeIThink.

On Fri, Apr 10, 2009 at 2:56 PM, John Seer <pu...@yahoo.com> wrote:

>
> Hello,
> I have 3 terms and I want to much them in order I tried to use wildcard
> query I am not getting any results back
>
> Terms: A C F
>
> Doc: name:A B C D E F
>
> query: name:A*C*F
>
> I am not getting any results back,
> Please any suggestions?
>
> Thanks for help in advance
> --
> View this message in context:
> http://www.nabble.com/Sequential-match-query-tp22995240p22995240.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>