You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Renaud Delbru <re...@deri.org> on 2008/02/02 20:48:31 UTC

SpanQuery support

Hi,

Do you know if it is currently possible to use the SpanQuery feature of 
Lucene in Solr 1.3. We would like to use nested span queries such as 
(("A B") near ("C D")).
Do a request handler support such feature ? Or, any idea how could we 
perform ?

Regards.

-- 
Renaud Delbru

Re: SpanQuery support

Posted by Renaud Delbru <re...@deri.org>.
Hi Yonik,

Yonik Seeley wrote:
> On Feb 2, 2008 3:43 PM, Renaud Delbru <re...@deri.org> wrote:
>   
>> I was looking at the discussion of SOLR-281. If I understand correctly,
>> the task would be to write my own search component class,
>> SpanQueryComponent that extends the SearchComponent class, then
>> overwriting the declaration of the "query searchComponent" in
>> solrconfig.xml:
>> <searchComponent name="query" class="my.package.SpanQueryComponent" />
>> Then, I will be able to use directly my own query syntax and query
>> component ? Is it correct ?
>>     
>
> You could, but that would be the hard way (by a big margin).
> There are pluggable query parsers now (see QParserPlugin)... but the
> current missing piece is being able to specify a new parser plugin
> from solrconfig.xml
>
> -Yonik
>   
Hum, I would prefer to follow the easiest way ;o).
Could you explain me briefly the easiest way ? And give me some hints on 
which classes I need to extend to achieve my goal ?

Regards.

-- 
Renaud Delbru,
E.C.S., Ph.D. Student,
Semantic Information Systems and
Language Engineering Group (SmILE),
Digital Enterprise Research Institute,
National University of Ireland, Galway.
http://smile.deri.ie/

Re: SpanQuery support

Posted by Renaud Delbru <re...@deri.org>.
Very nice, I will try this approach.

Thanks Yonik.

Yonik Seeley wrote:
> On Feb 4, 2008 11:53 AM, Yonik Seeley <yo...@apache.org> wrote:
>   
>> You could, but that would be the hard way (by a big margin).
>> There are pluggable query parsers now (see QParserPlugin)... but the
>> current missing piece is being able to specify a new parser plugin
>> from solrconfig.xml
>>     
>
> Hmmm, it appears I forgot what I implemented already ;-)
>
> Support for adding new parser plugins from solrconfig.xml already
> exists (and I just added a test).
> So add something like the following to your solrconfig.xml
> <queryParser name="foo" class="FooQParserPlugin"/>
>
> And then implement FooQParserPlugin in Java to create your desired
> query structures (span queries or whatever).  See other
> implementations of FooQParserPlugin in Solr for guidance.
>
> To use your "foo" parser, set it to the default query type by adding
> defType="foo" to the request (or to the defaults for your handler).
> You can also override the current query type via q=<!foo>my query
>
>
> -Yonik
>   


-- 
Renaud Delbru,
E.C.S., Ph.D. Student,
Semantic Information Systems and
Language Engineering Group (SmILE),
Digital Enterprise Research Institute,
National University of Ireland, Galway.
http://smile.deri.ie/

Re: SpanQuery support

Posted by Yonik Seeley <yo...@apache.org>.
On Feb 4, 2008 11:53 AM, Yonik Seeley <yo...@apache.org> wrote:
> You could, but that would be the hard way (by a big margin).
> There are pluggable query parsers now (see QParserPlugin)... but the
> current missing piece is being able to specify a new parser plugin
> from solrconfig.xml

Hmmm, it appears I forgot what I implemented already ;-)

Support for adding new parser plugins from solrconfig.xml already
exists (and I just added a test).
So add something like the following to your solrconfig.xml
<queryParser name="foo" class="FooQParserPlugin"/>

And then implement FooQParserPlugin in Java to create your desired
query structures (span queries or whatever).  See other
implementations of FooQParserPlugin in Solr for guidance.

To use your "foo" parser, set it to the default query type by adding
defType="foo" to the request (or to the defaults for your handler).
You can also override the current query type via q=<!foo>my query


-Yonik

Re: SpanQuery support

Posted by Renaud Delbru <re...@deri.org>.
Yonik Seeley wrote:
> On Feb 2, 2008 3:43 PM, Renaud Delbru <re...@deri.org> wrote:
>   
>> I was looking at the discussion of SOLR-281. If I understand correctly,
>> the task would be to write my own search component class,
>> SpanQueryComponent that extends the SearchComponent class, then
>> overwriting the declaration of the "query searchComponent" in
>> solrconfig.xml:
>> <searchComponent name="query" class="my.package.SpanQueryComponent" />
>> Then, I will be able to use directly my own query syntax and query
>> component ? Is it correct ?
>>     
>
> You could, but that would be the hard way (by a big margin).
> There are pluggable query parsers now (see QParserPlugin)... but the
> current missing piece is being able to specify a new parser plugin
> from solrconfig.xml
>
> -Yonik
>   
I have looked at MoreLikeThisHandler.java. I saw that all the 
MoreLikeThis logics is defined inside the handler and through the inner 
class MoreLikeThisHelper.
Could I follow the same approach and define a ProximityHandler class 
that execute Lucene SpanQuery based on some request parameters ? Is it 
the right way to do ?

Regards.

-- 
Renaud Delbru,
E.C.S., Ph.D. Student,
Semantic Information Systems and
Language Engineering Group (SmILE),
Digital Enterprise Research Institute,
National University of Ireland, Galway.
http://smile.deri.ie/

Re: SpanQuery support

Posted by Yonik Seeley <yo...@apache.org>.
On Feb 2, 2008 3:43 PM, Renaud Delbru <re...@deri.org> wrote:
> I was looking at the discussion of SOLR-281. If I understand correctly,
> the task would be to write my own search component class,
> SpanQueryComponent that extends the SearchComponent class, then
> overwriting the declaration of the "query searchComponent" in
> solrconfig.xml:
> <searchComponent name="query" class="my.package.SpanQueryComponent" />
> Then, I will be able to use directly my own query syntax and query
> component ? Is it correct ?

You could, but that would be the hard way (by a big margin).
There are pluggable query parsers now (see QParserPlugin)... but the
current missing piece is being able to specify a new parser plugin
from solrconfig.xml

-Yonik

Re: SpanQuery support

Posted by Renaud Delbru <re...@deri.org>.
Thanks Yonik,

I was looking at the discussion of SOLR-281. If I understand correctly, 
the task would be to write my own search component class, 
SpanQueryComponent that extends the SearchComponent class, then 
overwriting the declaration of the "query searchComponent" in 
solrconfig.xml:
<searchComponent name="query" class="my.package.SpanQueryComponent" />
Then, I will be able to use directly my own query syntax and query 
component ? Is it correct ?

Regards.

Yonik Seeley wrote:
> Solr 1.3 will have query parser plugins... so you could write your own
> parser that utilized span queries.
> -Yonik
>
> On Feb 2, 2008 2:48 PM, Renaud Delbru <re...@deri.org> wrote:
>   
>> Do you know if it is currently possible to use the SpanQuery feature of
>> Lucene in Solr 1.3. We would like to use nested span queries such as
>> (("A B") near ("C D")).
>> Do a request handler support such feature ? Or, any idea how could we
>> perform ?
>>     


-- 
Renaud Delbru,
E.C.S., Ph.D. Student,
Semantic Information Systems and
Language Engineering Group (SmILE),
Digital Enterprise Research Institute,
National University of Ireland, Galway.
http://smile.deri.ie/

Re: SpanQuery support

Posted by Yonik Seeley <yo...@apache.org>.
Solr 1.3 will have query parser plugins... so you could write your own
parser that utilized span queries.
-Yonik

On Feb 2, 2008 2:48 PM, Renaud Delbru <re...@deri.org> wrote:
> Do you know if it is currently possible to use the SpanQuery feature of
> Lucene in Solr 1.3. We would like to use nested span queries such as
> (("A B") near ("C D")).
> Do a request handler support such feature ? Or, any idea how could we
> perform ?