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 RONALD MANTAY <ro...@btinternet.com> on 2006/02/07 22:06:51 UTC
How can you simulate inOrder in boolean queries
Hi, can any one help, I am new to lucene.
Due to requiring a specific Query syntax, I have created a bespoke query parser to build a boolean query which at any time may comprising a mixture of :
a) Fuzzy terms with similarity level set according to length of term.text
b) Wild Card Querys
c) Term Querys
I would like to ability to define if the Query parser terms require to be in Order or not (but when in order to allow gaps in the term positions).
I can not see see how I can use PhraseQuery or SpanNearQuery directly, can anyone point me in the right direction in how to simulate inOrder to boolean queries.
Any help will be appreciated.
Re: How can you simulate inOrder in boolean queries
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
The source code to Lucene in Action (www.lucenebook.com) has an
example of extending the built-in QueryParser to use SpanNearQuery
for in-order phrase searching instead of the default unordered
PhraseQuery behavior. That example will show how to use
SpanNearQuery made up of SpanTermQuery's. The source code to
QueryParser <http://svn.apache.org/repos/asf/lucene/java/trunk/src/
java/org/apache/lucene/queryParser/QueryParser.jj> shows how to use
PhraseQuery directly, if all you want is an example.
Also as Paul mentioned, the test cases in Lucene's source code make
great ways to learn how Lucene's API works.
If what you're trying to do is put an in-order wrapper around all of
the query types you mentioned, you will have a fair bit more work to
do in order to create a parser that can create a SpanNearQuery with
SpanRegexQuery's (new in contrib's trunk), and there currently is not
a SpanQuery version of FuzzyQuery that I'm aware of.
Erik
On Feb 7, 2006, at 4:06 PM, RONALD MANTAY wrote:
> Hi, can any one help, I am new to lucene.
>
> Due to requiring a specific Query syntax, I have created a
> bespoke query parser to build a boolean query which at any time may
> comprising a mixture of :
>
> a) Fuzzy terms with similarity level set according to length of
> term.text
> b) Wild Card Querys
> c) Term Querys
>
> I would like to ability to define if the Query parser terms
> require to be in Order or not (but when in order to allow gaps in
> the term positions).
>
> I can not see see how I can use PhraseQuery or SpanNearQuery
> directly, can anyone point me in the right direction in how to
> simulate inOrder to boolean queries.
>
> Any help will be appreciated.
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How can you simulate inOrder in boolean queries
Posted by Paul Elschot <pa...@xs4all.nl>.
On Tuesday 07 February 2006 22:06, RONALD MANTAY wrote:
> Hi, can any one help, I am new to lucene.
>
> Due to requiring a specific Query syntax, I have created a bespoke query
parser to build a boolean query which at any time may comprising a mixture
of :
>
> a) Fuzzy terms with similarity level set according to length of term.text
> b) Wild Card Querys
> c) Term Querys
>
> I would like to ability to define if the Query parser terms require to be
in Order or not (but when in order to allow gaps in the term positions).
>
> I can not see see how I can use PhraseQuery or SpanNearQuery directly, can
anyone point me in the right direction in how to simulate inOrder to boolean
queries.
You could take a look at the test code for these classes, this contains
examples on their use (see eg. TestPhraseQuery and the spans directory):
http://svn.apache.org/viewcvs.cgi/lucene/java/tags/lucene_1_4_3/src/test/org/apache/lucene/search/
And there is also another query language that has ordered and
unordered queries:
http://svn.apache.org/viewcvs.cgi/lucene/java/trunk/contrib/surround/
Regards,
Paul Elschot
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org