lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Lucene 3.5 Query Parser Question
Date Wed, 11 Jul 2012 16:56:51 GMT
I think you'll have to build the query up in code.  RegexQuery in the
contrib queries package should be able to take care of #[0-9].

BooleanQuery bq = new BooleanQuery();
PrefixQuery pq = new PrefixQuery(...) // #
RegexQuery rq = new RegexQuery(...) // #[0-9]
bq.add(pq, ....);
bq.add(rq, ...);

and search using bq.

Or you could extend QueryParser to produce the queries you need.  I'd
do it the first way.


--
Ian.


On Wed, Jul 11, 2012 at 5:40 PM, Dave Seltzer <dseltzer@tveyes.com> wrote:
> Hello,
>
> I'm interested in searching a MemoryIndex to find occurrences of HashTags.
>
> To do this I'm trying to use the following query:
> #* -#[0 TO 9]
>
> My goal with this query is to look for any word starting with "#" except
> for words like "#1".
>
> However, when I parse this query, the query parser turns it into this:
> +content:#* -content:# +content:[0 TO 9]
>
> Effectively the QueryParser is splitting up the "#" and the "[0 TO 9]"
>
> The same behavior occurs when I run this: #* -(#[0 TO 9])
>
> Can anyone help me rewrite this query?
>
> Thanks so much
>
> -Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

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


Mime
View raw message