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 reeja <d....@gmail.com> on 2007/11/27 08:47:32 UTC

prefix query search problem if a hyphen exist in the search word

Hi,
 I faced some problem with prefix query search when the prefix text contains
a hyphen. i'm using lucene-2.1.
Search query is like this ttl:co-operative it returns more than 50 results,
but if i convert the query like this ttl:co-operat* it  returns no result.
again i entered a query ttl:11-amino it returns some results, then  changed
the above query into ttl:11-amino* it will return some more results than
previous query.
I think if a character or text appeared before the hyphen may  cause the
pbroblem, if the text before hyphen is a number its work fine.
anybody can help me to correct this problem.

Thanks
reeja


-- 
View this message in context: http://www.nabble.com/prefix-query-search-problem-if-a-hyphen-exist-in-the-search-word-tf4880266.html#a13966231
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: prefix query search problem if a hyphen exist in the search word

Posted by reeja <d....@gmail.com>.
Yes, i am using standard analyzer both at indexing and query time.


Erick Erickson wrote:
> 
> What analyzers are you using both at index time and
> query time? StandardAnalyzer will, for instance, split
> the words at the hyphen.
> 
> I would recommend that you get a copy of Luke (google
> lucene luke) and examine both the contents of your index,
> and the query produced by using various analyzers. Also,
> query.toString() will show you a lot about
> what is actually happening.
> 
> Best
> Erick
> 
> On Nov 27, 2007 2:47 AM, reeja <d....@gmail.com> wrote:
> 
>>
>> Hi,
>>  I faced some problem with prefix query search when the prefix text
>> contains
>> a hyphen. i'm using lucene-2.1.
>> Search query is like this ttl:co-operative it returns more than 50
>> results,
>> but if i convert the query like this ttl:co-operat* it  returns no
>> result.
>> again i entered a query ttl:11-amino it returns some results, then
>>  changed
>> the above query into ttl:11-amino* it will return some more results than
>> previous query.
>> I think if a character or text appeared before the hyphen may  cause the
>> pbroblem, if the text before hyphen is a number its work fine.
>> anybody can help me to correct this problem.
>>
>> Thanks
>> reeja
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/prefix-query-search-problem-if-a-hyphen-exist-in-the-search-word-tf4880266.html#a13966231
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/prefix-query-search-problem-if-a-hyphen-exist-in-the-search-word-tf4880266.html#a14042394
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: prefix query search problem if a hyphen exist in the search word

Posted by Erick Erickson <er...@gmail.com>.
What analyzers are you using both at index time and
query time? StandardAnalyzer will, for instance, split
the words at the hyphen.

I would recommend that you get a copy of Luke (google
lucene luke) and examine both the contents of your index,
and the query produced by using various analyzers. Also,
query.toString() will show you a lot about
what is actually happening.

Best
Erick

On Nov 27, 2007 2:47 AM, reeja <d....@gmail.com> wrote:

>
> Hi,
>  I faced some problem with prefix query search when the prefix text
> contains
> a hyphen. i'm using lucene-2.1.
> Search query is like this ttl:co-operative it returns more than 50
> results,
> but if i convert the query like this ttl:co-operat* it  returns no result.
> again i entered a query ttl:11-amino it returns some results, then
>  changed
> the above query into ttl:11-amino* it will return some more results than
> previous query.
> I think if a character or text appeared before the hyphen may  cause the
> pbroblem, if the text before hyphen is a number its work fine.
> anybody can help me to correct this problem.
>
> Thanks
> reeja
>
>
> --
> View this message in context:
> http://www.nabble.com/prefix-query-search-problem-if-a-hyphen-exist-in-the-search-word-tf4880266.html#a13966231
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: prefix query search problem if a hyphen exist in the search word

Posted by Chris Hostetter <ho...@fucit.org>.
: Search query is like this ttl:co-operative it returns more than 50 results,
: but if i convert the query like this ttl:co-operat* it  returns no result.
: again i entered a query ttl:11-amino it returns some results, then  changed
: the above query into ttl:11-amino* it will return some more results than
: previous query.

if you'd searched the FAQ for "prefix" you would have found this 
question...

  Are Wildcard, Prefix, and Fuzzy queries case sensitive?

that may not seem like it relates to your problem, but if you read the 
answer...

  No, not by default. Unlike other types of Lucene queries, Wildcard, 
  Prefix, and Fuzzy queries are not passed through the Analyzer, which is 
  the component that performs operations such as stemming and lowercasing. 
  The reason for skipping the Analyzer is that if you were searching for 
  "dogs*" you would not want "dogs" first stemmed to "dog", since that would 
  then match "dog*", which is not the intended query. These queries are 
  case-insensitive anyway because QueryParser makes them lowercase. This 
  behavior can be changed using the setLowercaseExpandedTerms(boolean) 
  method.

...the key being that wildcard and prefix queries aren't analyzed, so if 
you are using an Analyzer that does something special with hyphens (like 
split on then perhaps) that would explain the behavior you are seeing.



-Hoss


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