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 Dinusha Dilrukshi <sd...@gmail.com> on 2013/10/08 09:32:32 UTC

Regex to match one of two words

I have an input that can have only 2 values Published or Deprecated. What
regular expression can I use to ensure that either of the two words was
submitted?

I tried with different regular expressions (as in the [1], [2]) that
contains most generic syntax.. But Solar throws parser exception when
validating these expressions.. Could someone help me on writing this
regular expression that will evaluate by the Solar parser.

[1] /^(PUBLISHED)?(DEPRECATED)?$/
[2] /(PUBLISHED)?(DEPRECATED)?/


SolrCore org.apache.solr.common.SolrException:
org.apache.lucene.queryParser.ParseException: Cannot parse
'overview_status_s:/(PUBLISHED)?(DEPRECATED)?/': '*' or '?' not allowed as
first character in WildcardQuery
at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:108)


Regards,
Dinusha.

Re: Regex to match one of two words

Posted by Walter Underwood <wu...@wunderwood.org>.
Or a boolean field for published, with false meaning deprecated.

wunder

On Oct 8, 2013, at 3:42 AM, Jack Krupansky wrote:

> Why use regular expressions at all?
> 
> Try:
> 
> published OR deprecated
> 
> -- Jack Krupansky
> 
> -----Original Message----- From: Dinusha Dilrukshi
> Sent: Tuesday, October 08, 2013 3:32 AM
> To: solr-user@lucene.apache.org
> Subject: Regex to match one of two words
> 
> I have an input that can have only 2 values Published or Deprecated. What
> regular expression can I use to ensure that either of the two words was
> submitted?
> 
> I tried with different regular expressions (as in the [1], [2]) that
> contains most generic syntax.. But Solar throws parser exception when
> validating these expressions.. Could someone help me on writing this
> regular expression that will evaluate by the Solar parser.
> 
> [1] /^(PUBLISHED)?(DEPRECATED)?$/
> [2] /(PUBLISHED)?(DEPRECATED)?/
> 
> 
> SolrCore org.apache.solr.common.SolrException:
> org.apache.lucene.queryParser.ParseException: Cannot parse
> 'overview_status_s:/(PUBLISHED)?(DEPRECATED)?/': '*' or '?' not allowed as
> first character in WildcardQuery
> at
> org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:108)
> 
> 
> Regards,
> Dinusha. 

--
Walter Underwood
wunder@wunderwood.org




Re: Regex to match one of two words

Posted by Jack Krupansky <ja...@basetechnology.com>.
Why use regular expressions at all?

Try:

published OR deprecated

-- Jack Krupansky

-----Original Message----- 
From: Dinusha Dilrukshi
Sent: Tuesday, October 08, 2013 3:32 AM
To: solr-user@lucene.apache.org
Subject: Regex to match one of two words

I have an input that can have only 2 values Published or Deprecated. What
regular expression can I use to ensure that either of the two words was
submitted?

I tried with different regular expressions (as in the [1], [2]) that
contains most generic syntax.. But Solar throws parser exception when
validating these expressions.. Could someone help me on writing this
regular expression that will evaluate by the Solar parser.

[1] /^(PUBLISHED)?(DEPRECATED)?$/
[2] /(PUBLISHED)?(DEPRECATED)?/


SolrCore org.apache.solr.common.SolrException:
org.apache.lucene.queryParser.ParseException: Cannot parse
'overview_status_s:/(PUBLISHED)?(DEPRECATED)?/': '*' or '?' not allowed as
first character in WildcardQuery
at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:108)


Regards,
Dinusha.