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 Daisy <om...@gmail.com> on 2012/10/23 14:08:31 UTC
Solr - Use Regex in the Query Phrase
Hi;
I am working with apache-solr-3.6.0 on windows machine. I would like to be
able to search for certain phrase which include some regex.
For example: I want my query to be: "art(.*?)le"
or another example of a phrase: "he sa*"
I dont know how to do that in the url that will be sent to solr. I would
like to be able to do something like that:
http://localhost:8983/solr/core0/select/?q="ar(.*?)cle"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
or
http://localhost:8983/solr/core0/select/?q="he
sa*"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
Here is the part of my schema that I am using
<fieldType name="text_ar" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
<field name="text" type="text_ar" indexed="true" stored="true"
termVectors="true" multiValued="true"/>
Any Ideas, please?
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr - Use Regex in the Query Phrase
Posted by Daisy <om...@gmail.com>.
Thanks very much, I have upgraded my solr to apache-solr-4.0 and my first
query works fine.
For the second one I have tried what iorixxx pointed out, but I couldnt
proceed. I am not experienced with patching, However i tried the steps
recommended by Ahmet Arslan here
<https://issues.apache.org/jira/browse/SOLR-1604> .
But it didnt works for me as it is always says class not found.
Could you please guide me how to use it to execute my second query? (I am
using windows)
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335p4015473.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr - Use Regex in the Query Phrase
Posted by Ahmet Arslan <io...@yahoo.com>.
> I think there is an alternative query parser that supports
> wildcards in phrases, but the name escapes me at the
> moment.
Yes, https://issues.apache.org/jira/browse/SOLR-1604
Re: Solr - Use Regex in the Query Phrase
Posted by Jack Krupansky <ja...@basetechnology.com>.
In 4.0, your first query can be done with a regex query - enclose the
pattern in slashes:
q=/art(.*?)le/
Wildcards, fuzzy query, and regex query can only be applied to a single
term, so you can't do your latter "proximity" query. The best you can do is
a conjunction:
q=he+sa*
Although in that specific case you might simply expand the terms and use
explicit terms in a proximity query:
q="he+says"+OR+"he+said"+OR+"he+saw"+OR+"he+saved"+OR+"he+saves"
I think there is an alternative query parser that supports wildcards in
phrases, but the name escapes me at the moment.
-- Jack Krupansky
-----Original Message-----
From: Daisy
Sent: Tuesday, October 23, 2012 8:08 AM
To: solr-user@lucene.apache.org
Subject: Solr - Use Regex in the Query Phrase
Hi;
I am working with apache-solr-3.6.0 on windows machine. I would like to be
able to search for certain phrase which include some regex.
For example: I want my query to be: "art(.*?)le"
or another example of a phrase: "he sa*"
I dont know how to do that in the url that will be sent to solr. I would
like to be able to do something like that:
http://localhost:8983/solr/core0/select/?q="ar(.*?)cle"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
or
http://localhost:8983/solr/core0/select/?q="he
sa*"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
Here is the part of my schema that I am using
<fieldType name="text_ar" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
<field name="text" type="text_ar" indexed="true" stored="true"
termVectors="true" multiValued="true"/>
Any Ideas, please?
--
View this message in context:
http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Solr - Use Regex in the Query Phrase
Posted by Daisy <om...@gmail.com>.
Ok, now I have apache-solr-4.0.0 on windows. And I am able to use the plugin
ComplexPhraseQuery as mentioned above.
So I can search for: For example: "art(.*?)le" or "he sa*". Thanks for all
help.
What if I want to search a phrase like that: "he (.*?) that"
in sentences like:
he said that
he is always saying that
he mentioned before that
...etc
Also I would like the phrase to be considered as one item in the phrase
frequency, i.e. I want to tell solr not considering "he" tf alone and "that"
tf alone. But I would like to know the "he (.*?) that" phrase frequency.
May be it is not a feature in solr.
Any way How could i execute a query like the one above??
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335p4015628.html
Sent from the Solr - User mailing list archive at Nabble.com.
RE: Solr - Use Regex in the Query Phrase
Posted by Markus Jelsma <ma...@openindex.io>.
Hi - Regex is not available in Solr 3.6:
https://issues.apache.org/jira/browse/LUCENE-2604
-----Original message-----
> From:Daisy <om...@gmail.com>
> Sent: Tue 23-Oct-2012 14:13
> To: solr-user@lucene.apache.org
> Subject: Solr - Use Regex in the Query Phrase
>
> Hi;
>
> I am working with apache-solr-3.6.0 on windows machine. I would like to be
> able to search for certain phrase which include some regex.
>
> For example: I want my query to be: "art(.*?)le"
> or another example of a phrase: "he sa*"
>
> I dont know how to do that in the url that will be sent to solr. I would
> like to be able to do something like that:
> http://localhost:8983/solr/core0/select/?q="ar(.*?)cle"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
>
> or
>
> http://localhost:8983/solr/core0/select/?q="he
> sa*"&version=2.2&start=0&rows=2&debugQuery=on&hl=true&hl.fl=*
>
>
> Here is the part of my schema that I am using
>
>
>
> <fieldType name="text_ar" class="solr.TextField"
> positionIncrementGap="100">
> <analyzer>
> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
> </analyzer>
> </fieldType>
>
>
> <field name="text" type="text_ar" indexed="true" stored="true"
> termVectors="true" multiValued="true"/>
>
> Any Ideas, please?
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
Re: Solr - Use Regex in the Query Phrase
Posted by Daisy <om...@gmail.com>.
Appreciate your help, it works now.
Thanks;
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-tp4015335p4015588.html
Sent from the Solr - User mailing list archive at Nabble.com.