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 Kashish <it...@gmail.com> on 2014/02/25 21:15:20 UTC

Re: Wildcard search not working if the query contains numbers along with special characters.

Hi Ahmet,

Thanks for your reply.

Yes. I pass my query this way - > q=title_autocomplete:1999%2f99

I tried your way too. But no luck. :( 




--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4119615.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Ahmet Arslan <io...@yahoo.com>.

Hi,

Forget about patternReplaceCharFilter for a moment. Your example is more clear this time.

q=titleName:1999/99*

should return following two docs:

d1) JULIUS CAESER (1999/99)

d2) ARABIAN NIGHTS - 1999/99


This is achievable with the following type. 

1) MappingCharFilterFactory with mappings.txt

"(" => ""
")" => ""

2) WhiteSpaceTokenizerFactory
3) LowercaseFilterFactory

I dont understand your sentence : "i will never be able to specifically search the title i want as 1999/99." 
But please try / test above. I also suggest you to use prefix query parser. 

https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-PrefixQueryParser

Ahmet



On Wednesday, March 5, 2014 11:20 PM, Kashish <it...@gmail.com> wrote:
Hi Ahmet,

Let me explain with another scenario .

There is a title ->  ARABIAN NIGHTS - 1999/99

Now in autocomplete, if i give 1999/99 , in the backend i append an asterisk
to it and form the solr url thsi way

q=titleName:1999/99*

I get the above mentioned title.- so works perfect

Now lets add another title to this.

-> JULIUS CAESER (1999/99)

If i pass the same query parameter, i would definitely expect both these
titles to come up. but this new one doesn't come(Because of the braces).

I can add patternReplaceFilter but this way i will never be able to
specifically search the title i want as 1999/99.

Hope you get what i am trying to achieve. Is my understanding wrong
somewhere?

Thanks.




--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4121512.html

Sent from the Solr - User mailing list archive at Nabble.com.


Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Kashish <it...@gmail.com>.
Hi Ahmet,

Let me explain with another scenario .

There is a title ->  ARABIAN NIGHTS - 1999/99

Now in autocomplete, if i give 1999/99 , in the backend i append an asterisk
to it and form the solr url thsi way

q=titleName:1999/99*

I get the above mentioned title.- so works perfect

Now lets add another title to this.

-> JULIUS CAESER (1999/99)

If i pass the same query parameter, i would definitely expect both these
titles to come up. but this new one doesn't come(Because of the braces).

I can add patternReplaceFilter but this way i will never be able to
specifically search the title i want as 1999/99.

Hope you get what i am trying to achieve. Is my understanding wrong
somewhere?

Thanks.




--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4121512.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi Kashish,

This is confusing. You gave the following example :

query 1999/99* should return RABIAN NIGHTS #01 (1999/99)

However you said "I cannot ignore parenthesis or other special characters..."

Above two contadicts each other.

Since you are after autocomplete you might be interested in this 
http://www.cominvent.com/2012/01/25/super-flexible-autocomplete-with-solr/

Ahmet


On Wednesday, March 5, 2014 8:36 PM, Kashish <it...@gmail.com> wrote:
Hi, Pls help me with this.



--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4121457.html

Sent from the Solr - User mailing list archive at Nabble.com.


Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Kashish <it...@gmail.com>.
Hi, Pls help me with this.



--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4121457.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Kashish <it...@gmail.com>.
Hi Erick,

I understand what you pointing out but the thing is.. this is for
autocomplete feature. I cannot ignore parenthesis or other special
characters as in certain titles like 'A Team of five', if the user fives 'a
team' then titles containing a-team and rest also comes off and this one
gets lost as we show only top 6 results (user can drill down to get closer
to the result he wants).
 
I modified my fieldtype so at index added worddelimeter delimeter and at
query time added patternfilter but now still if i use asterisk i get no
records for 1999/99* but get without asterisk. Thsi is not what i want as by
default, whatever the user enters we append asterisk to it for autocomplete
search.

Thanks



--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4121205.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Erick Erickson <er...@gmail.com>.
The admin/analysis page is your friend. Taking some time to
get acquainted with that page will save you lots and lots and
lots of time. In this case, you'd have seen that your input
is actually tokenized as (1999/99), parentheses and all as a
_single_ token, so of course searching for 1999/99 wouldn't work.

Searching for *1999/99* is generally a bad idea. It'll work, but it's
a kludge.

What you _do_ need to do is define your use-cases. Let's
assume that you _never_ want parentheses to be relevant. You
could use PatternReplaceCharFilterFactory or PatternReplaceFilterFactory
in both index and query parts of your analysis chain to remove
parens. Or really any kinds of extraneous characters you decided
were unimportant.

But you need to decide what's "important" and enforce that.

Best,
Erick


On Tue, Feb 25, 2014 at 7:28 PM, Kashish <it...@gmail.com> wrote:

> Hi Ahmet/Erick,
>
> I tried escaping as well. See no luck.
>
> The title am looking for is  - ARABIAN NIGHTS #01 (1999/99)
>
> I figured out that if i pass the query as *1999/99* (i.e asterisk not only
> at the end but at the beginning as well), It works.
>
> The problem is the braces. I can change my field type and add
>
>  <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1"
> generateNumberParts="1" catenateWords="1" catenateNumbers="1"
> catenateAll="0" splitOnCaseChange="1" preserveOriginal="1"/>
>
> But this will show too many results in autocomplete.
>
> Is there any best way to handle this? Or should i pass asterisk before and
> after the query?
>
> Thanks.
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4119678.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Kashish <it...@gmail.com>.
Hi Ahmet/Erick,

I tried escaping as well. See no luck.

The title am looking for is  - ARABIAN NIGHTS #01 (1999/99)

I figured out that if i pass the query as *1999/99* (i.e asterisk not only
at the end but at the beginning as well), It works.

The problem is the braces. I can change my field type and add 

 <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1"
generateNumberParts="1" catenateWords="1" catenateNumbers="1"
catenateAll="0" splitOnCaseChange="1" preserveOriginal="1"/>

But this will show too many results in autocomplete.

Is there any best way to handle this? Or should i pass asterisk before and
after the query?

Thanks.




--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4119678.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Wildcard search not working if the query contains numbers along with special characters.

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi,

By saying escaping I mean this : q=title_autocomplete:1999\/99*   It is different than URL encoding.

http://lucene.apache.org/core/4_6_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters

If prefix query parser didn't return what you want then it must be something with indexed terms.

Can you give an example raw documents text that you expect to retrieve with this query?



On Tuesday, February 25, 2014 10:15 PM, Kashish <it...@gmail.com> wrote:
Hi Ahmet,

Thanks for your reply.

Yes. I pass my query this way - > q=title_autocomplete:1999%2f99

I tried your way too. But no luck. :( 




--
View this message in context: http://lucene.472066.n3.nabble.com/Wildcard-search-not-working-if-the-query-conatins-numbers-along-with-special-characters-tp4119608p4119615.html

Sent from the Solr - User mailing list archive at Nabble.com.