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.

Reply via email to