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 Chris Salem <ch...@mainsequence.net> on 2011/04/29 15:54:42 UTC

ComplexPhraseQueryParser with multiple fields

Hi,
I've just started using the ComplexPhraseQueryParser and it works great with one field but is there a way for it to work with multiple fields?  For example, right now the query:
job_title: "sales man*" AND NOT contact_name: "Chris Salem"
throws this exception 
Caused by: org.apache.lucene.queryParser.ParseException: Cannot have clause for field "job_title" nested in phrase for field "contact_name"
What is the best way to work around this?
Sincerely,
Chris Salem

Re: ComplexPhraseQueryParser with multiple fields

Posted by Ahmet Arslan <io...@yahoo.com>.

Hi,
I've just started using the ComplexPhraseQueryParser and it works great with one field but is there a way for it to work with multiple fields?  For example, right now the query:
job_title: "sales man*" AND NOT contact_name: "Chris Salem"
throws this exception 
Caused by: org.apache.lucene.queryParser.ParseException: Cannot have clause for field "job_title" nested in phrase for field "contact_name"
What is the best way to work around this?

There is "Lucene-1486 non default field.patch" for that but it requires :

"Fixing this would require changing the package name of 
ComplexPhraseQueryParser or changing the visibility of "field" in the 
QueryParser base class to "protected".
Anyone have any strong feelings about which of these is the most acceptable?" 

https://issues.apache.org/jira/browse/LUCENE-1486


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


Re: ComplexPhraseQueryParser with multiple fields

Posted by lichman <li...@gmail.com>.
The same as touch*.
Thanks.

--
View this message in context: http://lucene.472066.n3.nabble.com/ComplexPhraseQueryParser-with-multiple-fields-tp2879290p3099824.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: ComplexPhraseQueryParser with multiple fields

Posted by Ahmet Arslan <io...@yahoo.com>.
> But now there's another issue. 
> I'm using SOLR and Lucene 3.1.0 and when sending a query
> "Wildcard* phrase*"
> it works as expected - but, when sending the query
> "wildcard*" (Only one
> word withing the phrase) I'm getting another exception:
> 
> HTTP ERROR: 500
> Unknown query type "org.apache.lucene.search.PrefixQuery"
> found in phrase
> query string "touch*"
> java.lang.IllegalArgumentException: Unknown query type
> "org.apache.lucene.search.PrefixQuery" found in phrase
> query string "touch*"


Actually query string "touch*" is invalid. It should be equivalent of just touch*. What is your expectation from that query?


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


Re: ComplexPhraseQueryParser with multiple fields

Posted by lichman <li...@gmail.com>.
Thanks! Now it works.

But now there's another issue. 
I'm using SOLR and Lucene 3.1.0 and when sending a query "Wildcard* phrase*"
it works as expected - but, when sending the query "wildcard*" (Only one
word withing the phrase) I'm getting another exception:

HTTP ERROR: 500
Unknown query type "org.apache.lucene.search.PrefixQuery" found in phrase
query string "touch*"
java.lang.IllegalArgumentException: Unknown query type
"org.apache.lucene.search.PrefixQuery" found in phrase query string "touch*"

Any ideas?

--
View this message in context: http://lucene.472066.n3.nabble.com/ComplexPhraseQueryParser-with-multiple-fields-tp2879290p3099495.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: ComplexPhraseQueryParser with multiple fields

Posted by Ahmet Arslan <io...@yahoo.com>.
> By the way - I'm using the
> ComplexPhraseQueryParser that I've downloaded
> from:
> 
> https://issues.apache.org/jira/browse/SOLR-1604
> 
> And I've tried to use packages:
> 
>  - org.apache.lucene.search
>  - org.apache.lucene.queryParser
> 
> Both, when compiled and added to the SOLR lib dir, caused
> the exception.

That's a different story then. You don't need to change anything. You can use it as plugin. However you need to embed the jar file into solr.war. Please follow the instructions described here :

https://issues.apache.org/jira/browse/SOLR-1604?focusedCommentId=12859048&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12859048

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


Re: ComplexPhraseQueryParser with multiple fields

Posted by lichman <li...@gmail.com>.
By the way - I'm using the ComplexPhraseQueryParser that I've downloaded
from:

https://issues.apache.org/jira/browse/SOLR-1604

And I've tried to use packages:

 - org.apache.lucene.search
 - org.apache.lucene.queryParser

Both, when compiled and added to the SOLR lib dir, caused the exception.

Any ideas?


--
View this message in context: http://lucene.472066.n3.nabble.com/ComplexPhraseQueryParser-with-multiple-fields-tp2879290p3099397.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: ComplexPhraseQueryParser with multiple fields

Posted by lichman <li...@gmail.com>.
Which patch are you referring to? The last one?
And sure... I'll do the voting thing.

--
View this message in context: http://lucene.472066.n3.nabble.com/ComplexPhraseQueryParser-with-multiple-fields-tp2879290p3099032.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: ComplexPhraseQueryParser with multiple fields

Posted by Ahmet Arslan <io...@yahoo.com>.
> Which of the solutions did you find to work better?
> Can you please say which package should I change it to if I
> choose to do it
> that way?

I think changing package name of ComplexQueryParser is easier. This way you can use existing patch directly.

Plus, do you mind voting https://issues.apache.org/jira/browse/LUCENE-1486? This will require creating a jira account if you don't  already have one.

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


Re: ComplexPhraseQueryParser with multiple fields

Posted by lichman <li...@gmail.com>.
Say,
Which of the solutions did you find to work better?
Can you please say which package should I change it to if I choose to do it
that way?

Thanks,
Moshe Lichman.


--
View this message in context: http://lucene.472066.n3.nabble.com/ComplexPhraseQueryParser-with-multiple-fields-tp2879290p3090213.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