lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ahmet Arslan (JIRA)" <>
Subject [jira] Commented: (LUCENE-1486) Wildcards, ORs etc inside Phrase queries
Date Fri, 24 Jul 2009 12:19:14 GMT


Ahmet Arslan commented on LUCENE-1486:

Hi everyone,

I am using your ComplexPhraseQueryParser. I integrated it into Solr. 
I am interested in it mainly because it supports OR operator and wildcards inside proximity

Specifically : "(john johathon) smith"~10   and   "j* smith"
They both work perfectly, thank you for your work.

I downloaded source code of it from
And then edited the code a little bit since I am using lucene 2.4.1:

I replaced those:
1-) TermRangeQuery to RangeQuery.
2-) getConstantScoreRewrite() to getUseOldRangeQuery();
3-) setConstantScoreRewrite(false); to setUseOldRangeQuery(true);
4-) On line 168 of there are two semicolons (;;)

I am not sure what I did is the way to start using this query parser with latest versions
of lucene/solr.
If it is not can you suggest me better ways or where to get/download latest source code of
query parser.

I am having problems with multi-field searches.

Query  "(john johathon) smith"~10 works on default field, e.g. text.

But when I want to run the same query on another field (other than default field)
title:"(john johathon) smith"~10 
it gives exception below:
Cannot have clause for field "text" nested in phrase for field "title"

When I ran the query distibuting field name to all terms it works:
title:"(title:john title:johathon) title:smith"~10

Is there an easy way to set field of all terms (without specifying)?

And about boosts of multi-field queries, is this query legal? (default operator = OR, default
field = text)

title:"(title:john title:johathon) title:smith"~10^1.5 OR "(john johathon) smith"~10^3.0

Shortly I want to use this queryparser to query on multi-fields with different boosts.

I am not sure if I am allowed to ask such question in here, if not please accept my apologies.

Thank you for your consideration.

Ahmet Arslan

> Wildcards, ORs etc inside Phrase queries
> ----------------------------------------
>                 Key: LUCENE-1486
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: QueryParser
>    Affects Versions: 2.4
>            Reporter: Mark Harwood
>            Assignee: Mark Harwood
>            Priority: Minor
>             Fix For: 2.9
>         Attachments:, junit_complex_phrase_qp_07_21_2009.patch,
junit_complex_phrase_qp_07_22_2009.patch, LUCENE-1486.patch, LUCENE-1486.patch, LUCENE-1486.patch,
> An extension to the default QueryParser that overrides the parsing of PhraseQueries to
allow more complex syntax e.g. wildcards in phrase queries.
> The implementation feels a little hacky - this is arguably better handled in QueryParser
itself. This works as a proof of concept  for much of the query parser syntax. Examples from
the Junit test include:
> 		checkMatches("\"j*   smyth~\"", "1,2"); //wildcards and fuzzies are OK in phrases
> 		checkMatches("\"(jo* -john)  smith\"", "2"); // boolean logic works
> 		checkMatches("\"jo*  smith\"~2", "1,2,3"); // position logic works.
> 		checkBadQuery("\"jo*  id:1 smith\""); //mixing fields in a phrase is bad
> 		checkBadQuery("\"jo* \"smith\" \""); //phrases inside phrases is bad
> 		checkBadQuery("\"jo* [sma TO smZ]\" \""); //range queries inside phrases not supported
> Code plus Junit test to follow...

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message