You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Nicolas Roduit <ni...@gmail.com> on 2013/02/08 08:49:04 UTC

Wildcard in a text field

I'm looking for a way of making a query on words which contain wildcards 
(* or ?). In general, we use wildcards in query, not in the text. I 
haven't find anything in Lucene to build that.

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


RE: Solr query parser, needs to call setAutoGeneratePhraseQueries(true)

Posted by "Zhang, Lisheng" <Li...@BroadVision.com>.
I am very sorry, I should have sent to solr user group, not lucene!!

Best regards, Lisheng

-----Original Message-----
From: Zhang, Lisheng 
Sent: Friday, February 08, 2013 12:17 PM
To: 'java-user@lucene.apache.org'
Subject: Solr query parser, needs to call
setAutoGeneratePhraseQueries(true)



Hi,

In our application we need to call method

setAutoGeneratePhraseQueries(true)

on lucene QueryParser, this is the way used to work in earlier versions
and it seems to me that is the much natural way?

But in current solr 3.6.1, the only way to do so is to set 

<luceneMatchVersion>LUCENE_30</luceneMatchVersion>

in solrconfig.xml (if I read souce code correctly), but I donot want to 
do so because this will change the whole behavior of lucene, and I only 
want to change this query parser behavior, not other lucene features?

Please guide me if there is a better way other than to change solr source
code?

Thanks very much for helps, Lisheng



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


Solr query parser, needs to call setAutoGeneratePhraseQueries(true)

Posted by "Zhang, Lisheng" <Li...@BroadVision.com>.
Hi,

In our application we need to call method

setAutoGeneratePhraseQueries(true)

on lucene QueryParser, this is the way used to work in earlier versions
and it seems to me that is the much natural way?

But in current solr 3.6.1, the only way to do so is to set 

<luceneMatchVersion>LUCENE_30</luceneMatchVersion>

in solrconfig.xml (if I read souce code correctly), but I donot want to 
do so because this will change the whole behavior of lucene, and I only 
want to change this query parser behavior, not other lucene features?

Please guide me if there is a better way other than to change solr source
code?

Thanks very much for helps, Lisheng



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


Re: Wildcard in a text field

Posted by Steve Rowe <sa...@gmail.com>.
Hi Nicolas,

For trailing '*' only: On the query side, you can use a front-side EdgeNGramTokenFilter with a large max gram size, followed by a PatternReplaceFilter with pattern "(.*)" and replacement "$1*".

Steve

On Feb 8, 2013, at 10:14 AM, Nicolas Roduit <Ni...@jmicrovision.com> wrote:

> For instance, I have a list of tags related to a text. Each text with its list of tags are put in a document and indexed by Lucene. If we consider that a tag is "buddh*" and I would like to make a query (e.g. "buddha" or "buddhism" or "buddhist") and find the document that contain "buddh*".
> 
> Thanks,
> 
> 
> Le 08. 02. 13 13:35, Jack Krupansky a écrit :
>> That description is too vague. Could you provide a couple of examples of index text and queries and what you expect those queries to match.
>> 
>> If you simply want to query for "*" and "?" in "string" fields, escape them with a backslash. But if you want to escape them in "text" fields, be sure to use an analyzer that preserves them since they generally will be treated as spaces.
>> 
>> -- Jack Krupansky
>> 
>> -----Original Message----- From: Nicolas Roduit
>> Sent: Friday, February 08, 2013 2:49 AM
>> To: java-user@lucene.apache.org
>> Subject: Wildcard in a text field
>> 
>> I'm looking for a way of making a query on words which contain wildcards
>> (* or ?). In general, we use wildcards in query, not in the text. I
>> haven't find anything in Lucene to build that.
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Wildcard in a text field

Posted by Jack Krupansky <ja...@basetechnology.com>.
Ah, okay... some people call that "prospective" search. In any case, there 
is no direct Lucene support that I know of.

There are some references here:
http://lucene.apache.org/core/4_0_0/memory/org/apache/lucene/index/memory/MemoryIndex.html

-- Jack Krupansky

-----Original Message----- 
From: Nicolas Roduit
Sent: Friday, February 08, 2013 10:14 AM
To: java-user@lucene.apache.org
Subject: Re: Re: Wildcard in a text field

For instance, I have a list of tags related to a text. Each text with
its list of tags are put in a document and indexed by Lucene. If we
consider that a tag is "buddh*" and I would like to make a query (e.g.
"buddha" or "buddhism" or "buddhist") and find the document that contain
"buddh*".

Thanks,


Le 08. 02. 13 13:35, Jack Krupansky a écrit :
> That description is too vague. Could you provide a couple of examples of 
> index text and queries and what you expect those queries to match.
>
> If you simply want to query for "*" and "?" in "string" fields, escape 
> them with a backslash. But if you want to escape them in "text" fields, be 
> sure to use an analyzer that preserves them since they generally will be 
> treated as spaces.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Nicolas Roduit
> Sent: Friday, February 08, 2013 2:49 AM
> To: java-user@lucene.apache.org
> Subject: Wildcard in a text field
>
> I'm looking for a way of making a query on words which contain wildcards
> (* or ?). In general, we use wildcards in query, not in the text. I
> haven't find anything in Lucene to build that.
>
> ---------------------------------------------------------------------
> 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
>
>


---------------------------------------------------------------------
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


Re: Re: Wildcard in a text field

Posted by Ian Lea <ia...@gmail.com>.
So you want a query for "buddhist" to match indexed term "budd*"?  Or
"bud* or "bu*" or "b*"?

Assuming you are using an analyzer that preserves the *, given
"buddhist" you could search for exactly "b*", "bu*" etc.

I'll let you think about ? rather than *.


--
Ian.


On Fri, Feb 8, 2013 at 3:14 PM, Nicolas Roduit
<Ni...@jmicrovision.com> wrote:
> For instance, I have a list of tags related to a text. Each text with its
> list of tags are put in a document and indexed by Lucene. If we consider
> that a tag is "buddh*" and I would like to make a query (e.g. "buddha" or
> "buddhism" or "buddhist") and find the document that contain "buddh*".
>
> Thanks,
>
>
> Le 08. 02. 13 13:35, Jack Krupansky a écrit :
>>
>> That description is too vague. Could you provide a couple of examples of
>> index text and queries and what you expect those queries to match.
>>
>> If you simply want to query for "*" and "?" in "string" fields, escape
>> them with a backslash. But if you want to escape them in "text" fields, be
>> sure to use an analyzer that preserves them since they generally will be
>> treated as spaces.
>>
>> -- Jack Krupansky
>>
>> -----Original Message----- From: Nicolas Roduit
>> Sent: Friday, February 08, 2013 2:49 AM
>> To: java-user@lucene.apache.org
>> Subject: Wildcard in a text field
>>
>> I'm looking for a way of making a query on words which contain wildcards
>> (* or ?). In general, we use wildcards in query, not in the text. I
>> haven't find anything in Lucene to build that.
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>
>
>
> ---------------------------------------------------------------------
> 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


Re: Re: Wildcard in a text field

Posted by Nicolas Roduit <Ni...@jmicrovision.com>.
For instance, I have a list of tags related to a text. Each text with 
its list of tags are put in a document and indexed by Lucene. If we 
consider that a tag is "buddh*" and I would like to make a query (e.g. 
"buddha" or "buddhism" or "buddhist") and find the document that contain 
"buddh*".

Thanks,


Le 08. 02. 13 13:35, Jack Krupansky a écrit :
> That description is too vague. Could you provide a couple of examples 
> of index text and queries and what you expect those queries to match.
>
> If you simply want to query for "*" and "?" in "string" fields, escape 
> them with a backslash. But if you want to escape them in "text" 
> fields, be sure to use an analyzer that preserves them since they 
> generally will be treated as spaces.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Nicolas Roduit
> Sent: Friday, February 08, 2013 2:49 AM
> To: java-user@lucene.apache.org
> Subject: Wildcard in a text field
>
> I'm looking for a way of making a query on words which contain wildcards
> (* or ?). In general, we use wildcards in query, not in the text. I
> haven't find anything in Lucene to build that.
>
> ---------------------------------------------------------------------
> 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
>
>


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


Re: Wildcard in a text field

Posted by Jack Krupansky <ja...@basetechnology.com>.
That description is too vague. Could you provide a couple of examples of 
index text and queries and what you expect those queries to match.

If you simply want to query for "*" and "?" in "string" fields, escape them 
with a backslash. But if you want to escape them in "text" fields, be sure 
to use an analyzer that preserves them since they generally will be treated 
as spaces.

-- Jack Krupansky

-----Original Message----- 
From: Nicolas Roduit
Sent: Friday, February 08, 2013 2:49 AM
To: java-user@lucene.apache.org
Subject: Wildcard in a text field

I'm looking for a way of making a query on words which contain wildcards
(* or ?). In general, we use wildcards in query, not in the text. I
haven't find anything in Lucene to build that.

---------------------------------------------------------------------
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