You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Atali Daoud <at...@gmail.com> on 2006/05/03 16:38:01 UTC

(Unknown)


Re:

Posted by Jeff Rodenburg <je...@gmail.com>.
Ali -

What you're looking at doing can get quite complex rather quickly, but if
you want to determine substitution patterns, look inside the QueryParser
class.  I would suggest trying to find a solution inside the objects,
though.  It's designed to handle the logic when you get a series of embedded
parentheticals and dealing with required/optional parameters.

-- j

On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:
>
> Thanks Jeff. That was very good information. What I want to get to the
> internal data structure which it uses to emit its expression. I want to
> grab essentially the prefix notation (or RPN, is that what is uses
> internally), so for example from (a & b), it would be +(a,b), which is
> prefix notation, so from here on, I can go just do in-order or preorder
> traversal to create my query.
>
>
>
> Beside that, Can I tell it to insert AND for +, OR for |, etc?
>
>
>
> Thanks
>
> Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com
> <ma...@microsoft.com>  | 972-365-9698
>
> ________________________________
>
> From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com]
> Sent: Wednesday, May 03, 2006 2:42 PM
> To: Ali Khawaja
> Cc: lucene-net-user@incubator.apache.org
> Subject: Re:
>
>
>
> The Lucene.Net API will provide either an object-based way to construct
> queries (TermQuery, SpanQuery, BooleanQuery, etc.) or allows a straight
> pass-through via static methods on the QueryParser object.  With the
> Query-class objects, you're passing in search terms and field names,
> then adding multiple objects to one consolidated query object.
>
> For your example, since you'd like to manipulate a user-entered query
> for "(a & b)", you would have to do parsing of the user's information.
> It would be easy enough to extend the query objects so that you could
> pass a statement such as "(a & b)" which emitted a logical Lucene
> expression of "+(FREETEXT:a) +(FREETEXT:b)".
>
> You'll have to handle interpretation of the parentheticals, pipes and
> ampersands to yield the results you'd like to see.  So yes, you'll have
> to do some work but the objects can take care of the other stuff for
> you.  Based on that symbol set, it shouldn't be too complex, either.
>
> Hope this helps.
>
> -- jeff
>
>
>
>
> On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:
>
> Hi Jeff -
>
> I am customizing sharepoint portal server(sps) for a client to provide
> msn/google/lucene style expression searching.
>
> So basically user should be able to provide Boolean expressions like:(a
> & b) ! c, etc. since this needs to be parsed and then assembled into a
> sps query, I am trying to see if I can use lucene for parser, get hold
> of the interim tree (or whatever data structure it creates), walk the
> tree and generate a sps query from there on.
>
>
>
> To give an example:
>
>
>
> if user enters (a & b), if will create something like
>
> FREETEXT("a") AND FREETEXT("b") - freetext is one of the query keywords
> in sps
>
>
>
> if the user enters a | b & c, it probably will be parsed as: a | (b &
> c), for which sps query would be:
>
> Freetext("a") OR (FREETEXT("b") AND FREETEXT("c")), etc
>
>
>
> So essentially I am trying to not code the expression parser and trying
> to figure out if there is something in lucene api that I can reuse. So I
> don't want the final result from the expression, I want the parsed
> result from which I can build my own query.
>
>
>
> Thanks
>
> Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com |
> 972-365-9698
>
>
>
>
>
> -----Original Message-----
> From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com]
> Sent: Wednesday, May 03, 2006 11:43 AM
> To: lucene-net-dev@incubator.apache.org
> Subject: Re:
>
>
>
> Hi Ali -
>
>
>
> Please send these messages to lucene-net-user@incubator.apache.org.  The
> dev
>
> mailing list is for Lucene.Net developers within Apache, not general
>
> developers using Lucene.Net.
>
>
>
> By parsing the expression, what input/output are you looking for?  Can
> you
>
> provide a sample?
>
>
>
> -- j
>
>
>
> On 5/3/06, Ali Khawaja < akhawaja@microsoft.com
> <ma...@microsoft.com> > wrote:
>
> >
>
> > Hi -
>
> >
>
> > Can anyone tell me if I can use Lucene as Boolean expression parser. I
>
>
> > need to handle the parsed tree by myself .
>
> >
>
> >
>
> >
>
> > Thanks
>
> >
>
> > Ali
>
> >
>
> >
>
> >
>
> >
>
> >
>
>
>
>
>

RE:

Posted by Ali Khawaja <ak...@microsoft.com>.
Thanks Jeff. That was very good information. What I want to get to the
internal data structure which it uses to emit its expression. I want to
grab essentially the prefix notation (or RPN, is that what is uses
internally), so for example from (a & b), it would be +(a,b), which is
prefix notation, so from here on, I can go just do in-order or preorder
traversal to create my query. 

 

Beside that, Can I tell it to insert AND for +, OR for |, etc?

 

Thanks

Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com
<ma...@microsoft.com>  | 972-365-9698

________________________________

From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com] 
Sent: Wednesday, May 03, 2006 2:42 PM
To: Ali Khawaja
Cc: lucene-net-user@incubator.apache.org
Subject: Re:

 

The Lucene.Net API will provide either an object-based way to construct
queries (TermQuery, SpanQuery, BooleanQuery, etc.) or allows a straight
pass-through via static methods on the QueryParser object.  With the
Query-class objects, you're passing in search terms and field names,
then adding multiple objects to one consolidated query object. 

For your example, since you'd like to manipulate a user-entered query
for "(a & b)", you would have to do parsing of the user's information.
It would be easy enough to extend the query objects so that you could
pass a statement such as "(a & b)" which emitted a logical Lucene
expression of "+(FREETEXT:a) +(FREETEXT:b)". 

You'll have to handle interpretation of the parentheticals, pipes and
ampersands to yield the results you'd like to see.  So yes, you'll have
to do some work but the objects can take care of the other stuff for
you.  Based on that symbol set, it shouldn't be too complex, either. 

Hope this helps.

-- jeff




On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote: 

Hi Jeff -

I am customizing sharepoint portal server(sps) for a client to provide
msn/google/lucene style expression searching.

So basically user should be able to provide Boolean expressions like:(a
& b) ! c, etc. since this needs to be parsed and then assembled into a
sps query, I am trying to see if I can use lucene for parser, get hold
of the interim tree (or whatever data structure it creates), walk the
tree and generate a sps query from there on. 

 

To give an example: 

 

if user enters (a & b), if will create something like

FREETEXT("a") AND FREETEXT("b") - freetext is one of the query keywords
in sps

 

if the user enters a | b & c, it probably will be parsed as: a | (b &
c), for which sps query would be:

Freetext("a") OR (FREETEXT("b") AND FREETEXT("c")), etc

 

So essentially I am trying to not code the expression parser and trying
to figure out if there is something in lucene api that I can reuse. So I
don't want the final result from the expression, I want the parsed
result from which I can build my own query.

 

Thanks

Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com |
972-365-9698

 

 

-----Original Message-----
From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com] 
Sent: Wednesday, May 03, 2006 11:43 AM
To: lucene-net-dev@incubator.apache.org
Subject: Re:

 

Hi Ali - 

 

Please send these messages to lucene-net-user@incubator.apache.org.  The
dev 

mailing list is for Lucene.Net developers within Apache, not general

developers using Lucene.Net.

 

By parsing the expression, what input/output are you looking for?  Can
you

provide a sample? 

 

-- j

 

On 5/3/06, Ali Khawaja < akhawaja@microsoft.com
<ma...@microsoft.com> > wrote:

> 

> Hi -

> 

> Can anyone tell me if I can use Lucene as Boolean expression parser. I


> need to handle the parsed tree by myself .

> 

> 

> 

> Thanks

> 

> Ali

> 

> 

> 

> 

> 

 


Re:

Posted by Jeff Rodenburg <je...@gmail.com>.
The Lucene.Net API will provide either an object-based way to construct
queries (TermQuery, SpanQuery, BooleanQuery, etc.) or allows a straight
pass-through via static methods on the QueryParser object.  With the
Query-class objects, you're passing in search terms and field names, then
adding multiple objects to one consolidated query object.

For your example, since you'd like to manipulate a user-entered query for
"(a & b)", you would have to do parsing of the user's information.  It would
be easy enough to extend the query objects so that you could pass a
statement such as "(a & b)" which emitted a logical Lucene expression of
"+(FREETEXT:a) +(FREETEXT:b)".

You'll have to handle interpretation of the parentheticals, pipes and
ampersands to yield the results you'd like to see.  So yes, you'll have to
do some work but the objects can take care of the other stuff for you.
Based on that symbol set, it shouldn't be too complex, either.

Hope this helps.

-- jeff



On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:
>
>  Hi Jeff -
>
> I am customizing sharepoint portal server(sps) for a client to provide
> msn/google/lucene style expression searching.
>
> So basically user should be able to provide Boolean expressions like:(a &
> b) ! c, etc. since this needs to be parsed and then assembled into a sps
> query, I am trying to see if I can use lucene for parser, get hold of the
> interim tree (or whatever data structure it creates), walk the tree and
> generate a sps query from there on.
>
>
>
> To give an example:
>
>
>
> if user enters (a & b), if will create something like
>
> FREETEXT("a") AND FREETEXT("b") – freetext is one of the query keywords in
> sps
>
>
>
> if the user enters a | b & c, it probably will be parsed as: a | (b & c),
> for which sps query would be:
>
> Freetext("a") OR (FREETEXT("b") AND FREETEXT("c")), etc
>
>
>
> So essentially I am trying to not code the expression parser and trying to
> figure out if there is something in lucene api that I can reuse. So I don't
> want the final result from the expression, I want the parsed result from
> which I can build my own query.
>
>
>
> Thanks
>
> Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com |
> 972-365-9698
>
>
>
>
>
> -----Original Message-----
> From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com]
> Sent: Wednesday, May 03, 2006 11:43 AM
> To: lucene-net-dev@incubator.apache.org
> Subject: Re:
>
>
>
> Hi Ali -
>
>
>
> Please send these messages to lucene-net-user@incubator.apache.org.  The
> dev
>
> mailing list is for Lucene.Net developers within Apache, not general
>
> developers using Lucene.Net.
>
>
>
> By parsing the expression, what input/output are you looking for?  Can you
>
> provide a sample?
>
>
>
> -- j
>
>
>
> On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:
>
> >
>
> > Hi -
>
> >
>
> > Can anyone tell me if I can use Lucene as Boolean expression parser. I
>
> > need to handle the parsed tree by myself.
>
> >
>
> >
>
> >
>
> > Thanks
>
> >
>
> > Ali
>
> >
>
> >
>
> >
>
> >
>
> >
>

RE:

Posted by Ali Khawaja <ak...@microsoft.com>.
Hi Jeff -

I am customizing sharepoint portal server(sps) for a client to provide
msn/google/lucene style expression searching.

So basically user should be able to provide Boolean expressions like:(a
& b) ! c, etc. since this needs to be parsed and then assembled into a
sps query, I am trying to see if I can use lucene for parser, get hold
of the interim tree (or whatever data structure it creates), walk the
tree and generate a sps query from there on. 

 

To give an example: 

 

if user enters (a & b), if will create something like

FREETEXT("a") AND FREETEXT("b") - freetext is one of the query keywords
in sps

 

if the user enters a | b & c, it probably will be parsed as: a | (b &
c), for which sps query would be:

Freetext("a") OR (FREETEXT("b") AND FREETEXT("c")), etc

 

So essentially I am trying to not code the expression parser and trying
to figure out if there is something in lucene api that I can reuse. So I
don't want the final result from the expression, I want the parsed
result from which I can build my own query.

 

Thanks

Ali Khawaja | Microsoft Consulting Services | akhawaja@microsoft.com |
972-365-9698

 

 

-----Original Message-----
From: Jeff Rodenburg [mailto:jeff.rodenburg@gmail.com] 
Sent: Wednesday, May 03, 2006 11:43 AM
To: lucene-net-dev@incubator.apache.org
Subject: Re:

 

Hi Ali -

 

Please send these messages to lucene-net-user@incubator.apache.org.  The
dev

mailing list is for Lucene.Net developers within Apache, not general

developers using Lucene.Net.

 

By parsing the expression, what input/output are you looking for?  Can
you

provide a sample?

 

-- j

 

On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:

> 

> Hi -

> 

> Can anyone tell me if I can use Lucene as Boolean expression parser. I

> need to handle the parsed tree by myself.

> 

> 

> 

> Thanks

> 

> Ali

> 

> 

> 

> 

> 


Re:

Posted by Jeff Rodenburg <je...@gmail.com>.
Hi Ali -

Please send these messages to lucene-net-user@incubator.apache.org.  The dev
mailing list is for Lucene.Net developers within Apache, not general
developers using Lucene.Net.

By parsing the expression, what input/output are you looking for?  Can you
provide a sample?

-- j

On 5/3/06, Ali Khawaja <ak...@microsoft.com> wrote:
>
> Hi -
>
> Can anyone tell me if I can use Lucene as Boolean expression parser. I
> need to handle the parsed tree by myself.
>
>
>
> Thanks
>
> Ali
>
>
>
>
>

RE:

Posted by Ali Khawaja <ak...@microsoft.com>.
Hi -

Can anyone tell me if I can use Lucene as Boolean expression parser. I
need to handle the parsed tree by myself.

 

Thanks

Ali