Regex expressions work on individual terms.  Positional information is 
irrelevant when it comes to regex matching - it's not matching across terms*.

The syntax allowed is documented here 
<https://lucene.apache.org/core/4_3_0/core/org/apache/lucene/util/automaton/RegExp.html>
 - it's not quite the full standard syntax.  ^ and $ aren't mentioned there.  
The beginning of the regex implicitly starts at the beginning of the term.

So whatever constitutes a "term" is the granularity of what matches.  "string" 
fields operate on the entire string.  A text field that is analyzed will regex 
match on the individual terms that emerge from the index-time analysis process.

        Erik

* Though with the surround query parser you can do proximity matching using 
wildcarded terms in sophisticated ways.

On May 22, 2013, at 16:42 , Lance Norskog wrote:

> If the indexed data includes positions, it should be possible to implement ^ 
> and $ as the first and last positions.
> 
> On 05/22/2013 04:08 AM, Oussama Jilal wrote:
>> There is no ^ or $ in the solr regex since the regular expression will match 
>> tokens (not the complete indexed text). So the results you get will basicly 
>> depend on your way of indexing, if you use the regex on a tokenized field 
>> and that is not what you want, try to use a copy field wich is not tokenized 
>> and then use the regex on that one.
>> 
>> On 05/22/2013 11:53 AM, Stéphane Habett Roux wrote:
>>> I just can't get the $ endpoint to work.
>>> 
>>>> I am not sure but I heard it works with the Java Regex engine (a little 
>>>> obvious if it is true ...), so any Java regex tutorial would help you.
>>>> 
>>>> On 05/22/2013 11:42 AM, Sagar Chaturvedi wrote:
>>>>> Yes, it works for me too. But many times result is not as expected. Is 
>>>>> there some guide on use of regex in solr?
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Oussama Jilal [mailto:jilal.ouss...@gmail.com]
>>>>> Sent: Wednesday, May 22, 2013 4:00 PM
>>>>> To: solr-user@lucene.apache.org
>>>>> Subject: Re: Regular expression in solr
>>>>> 
>>>>> I don't think so, it always worked for me without anything special, just 
>>>>> try it and see :)
>>>>> 
>>>>> On 05/22/2013 11:26 AM, Sagar Chaturvedi wrote:
>>>>>> @Oussama Thank you for your reply. Is it as simple as that? I mean no 
>>>>>> additional settings required?
>>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: Oussama Jilal [mailto:jilal.ouss...@gmail.com]
>>>>>> Sent: Wednesday, May 22, 2013 3:37 PM
>>>>>> To: solr-user@lucene.apache.org
>>>>>> Subject: Re: Regular expression in solr
>>>>>> 
>>>>>> You can write a regular expression query like this (you need to specify 
>>>>>> the regex between slashes / ) :
>>>>>> 
>>>>>> fieldName:/[rR]egular.*/
>>>>>> 
>>>>>> On 05/22/2013 10:51 AM, Sagar Chaturvedi wrote:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> How do we search based upon regular expressions in solr?
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Sagar
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> DISCLAIMER:
>>>>>>> --------------------------------------------------------------------- 
>>>>>>> -
>>>>>>> -------------------------------------------------
>>>>>>> The contents of this e-mail and any attachment(s) are confidential
>>>>>>> and intended for the named recipient(s) only.
>>>>>>> It shall not attach any liability on the originator or NEC or its
>>>>>>> affiliates. Any views or opinions presented in this email are solely
>>>>>>> those of the author and may not necessarily reflect the opinions of
>>>>>>> NEC or its affiliates.
>>>>>>> Any form of reproduction, dissemination, copying, disclosure,
>>>>>>> modification, distribution and / or publication of this message
>>>>>>> without the prior written consent of the author of this e-mail is
>>>>>>> strictly prohibited. If you have received this email in error please
>>>>>>> delete it and notify the sender immediately. .
>>>>>>> --------------------------------------------------------------------- 
>>>>>>> -
>>>>>>> -------------------------------------------------
>>>>>> 
>>>>>> DISCLAIMER:
>>>>>> ---------------------------------------------------------------------- 
>>>>>> -------------------------------------------------
>>>>>> The contents of this e-mail and any attachment(s) are confidential and
>>>>>> intended for the named recipient(s) only.
>>>>>> It shall not attach any liability on the originator or NEC or its
>>>>>> affiliates. Any views or opinions presented in this email are solely
>>>>>> those of the author and may not necessarily reflect the opinions of
>>>>>> NEC or its affiliates.
>>>>>> Any form of reproduction, dissemination, copying, disclosure,
>>>>>> modification, distribution and / or publication of this message
>>>>>> without the prior written consent of the author of this e-mail is
>>>>>> strictly prohibited. If you have received this email in error please
>>>>>> delete it and notify the sender immediately. .
>>>>>> ---------------------------------------------------------------------- 
>>>>>> -------------------------------------------------
>>>>> 
>>>>> 
>>>>> DISCLAIMER:
>>>>> -----------------------------------------------------------------------------------------------------------------------
>>>>>  
>>>>> The contents of this e-mail and any attachment(s) are confidential and
>>>>> intended
>>>>> for the named recipient(s) only.
>>>>> It shall not attach any liability on the originator or NEC or its
>>>>> affiliates. Any views or opinions presented in
>>>>> this email are solely those of the author and may not necessarily reflect 
>>>>> the
>>>>> opinions of NEC or its affiliates.
>>>>> Any form of reproduction, dissemination, copying, disclosure, 
>>>>> modification,
>>>>> distribution and / or publication of
>>>>> this message without the prior written consent of the author of this 
>>>>> e-mail is
>>>>> strictly prohibited. If you have
>>>>> received this email in error please delete it and notify the sender
>>>>> immediately. .
>>>>> -----------------------------------------------------------------------------------------------------------------------
>>>>>  
>> 
> 

Reply via email to