wildcard search doesn't fetch results when field has white spaces and special charecters

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

wildcard search doesn't fetch results when field has white spaces and special charecters

Ahemad Ali
Hi ,
I have field with white spaces and special characters on which indexing needs to be done to do wildcard querying.
It works for most of the scnearios with wildcard search.
e.g. if my data is "ali.abc" and "abc_pqr" and "ali abc" and "ahemad ali" then search with ali* gives this three results.

But I am not able to search with say -  ali a*

Search with query q="ali abc" gives exact match and desired result.

I want to do wildcard search where criteria can include spaces like example - "ahemad a* or ahemad a*


i.e. if space is present then I am not able to to wildcard search.

Is there any way by which wildcard search will be achieved even if space is present in token.

The field type have is below:

    <fieldType name="string_rev"class="solr.TextField" sortMissingLast="true">

    <analyzer type="index">

        <tokenizerclass="solr.KeywordTokenizerFactory"/>

        <filterclass="solr.LowerCaseFilterFactory" />

        <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]" replacement=""replace="all" />

        <filterclass="solr.ReversedWildcardFilterFactory" />

    </analyzer>

    <analyzer type="query">

        <tokenizerclass="solr.KeywordTokenizerFactory"/>

        <filterclass="solr.LowerCaseFilterFactory" />

        <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]" replacement=""replace="all" />

    </analyzer>

</fieldType>
Any help would be great.
Thanks,Ahemad Ali
Reply | Threaded
Open this post in threaded view
|

Re: wildcard search doesn't fetch results when field has white spaces and special charecters

Erick Erickson
Try complexphrasequeryparser. If (and only if) you always want to search
from the beginning of the content, you might be able to use string rather
than text-based Fields but make sure to escape whitespace...

Best,
Erick

On Sat, Mar 30, 2019, 10:33 [hidden email]
<[hidden email]> wrote:

> Hi ,
> I have field with white spaces and special characters on which indexing
> needs to be done to do wildcard querying.
> It works for most of the scnearios with wildcard search.
> e.g. if my data is "ali.abc" and "abc_pqr" and "ali abc" and "ahemad ali"
> then search with ali* gives this three results.
>
> But I am not able to search with say -  ali a*
>
> Search with query q="ali abc" gives exact match and desired result.
>
> I want to do wildcard search where criteria can include spaces like
> example - "ahemad a* or ahemad a*
>
>
> i.e. if space is present then I am not able to to wildcard search.
>
> Is there any way by which wildcard search will be achieved even if space
> is present in token.
>
> The field type have is below:
>
>     <fieldType name="string_rev"class="solr.TextField"
> sortMissingLast="true">
>
>     <analyzer type="index">
>
>         <tokenizerclass="solr.KeywordTokenizerFactory"/>
>
>         <filterclass="solr.LowerCaseFilterFactory" />
>
>         <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
> replacement=""replace="all" />
>
>         <filterclass="solr.ReversedWildcardFilterFactory" />
>
>     </analyzer>
>
>     <analyzer type="query">
>
>         <tokenizerclass="solr.KeywordTokenizerFactory"/>
>
>         <filterclass="solr.LowerCaseFilterFactory" />
>
>         <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
> replacement=""replace="all" />
>
>     </analyzer>
>
> </fieldType>
> Any help would be great.
> Thanks,Ahemad Ali
Reply | Threaded
Open this post in threaded view
|

Re: wildcard search doesn't fetch results when field has whi

Ahemad Ali
Erick,I tried complexqueryparser, still no result.Escape white space, do you mean to say using "\" ?Thanks,Ahemad 

Sent from Yahoo Mail on Android
 
  On Sun, Mar 31, 2019 at 1:22, Erick Erickson<[hidden email]> wrote:   Try complexphrasequeryparser. If (and only if) you always want to search
from the beginning of the content, you might be able to use string rather
than text-based Fields but make sure to escape whitespace...

Best,
Erick

On Sat, Mar 30, 2019, 10:33 [hidden email]
<[hidden email]> wrote:

> Hi ,
> I have field with white spaces and special characters on which indexing
> needs to be done to do wildcard querying.
> It works for most of the scnearios with wildcard search.
> e.g. if my data is "ali.abc" and "abc_pqr" and "ali abc" and "ahemad ali"
> then search with ali* gives this three results.
>
> But I am not able to search with say -  ali a*
>
> Search with query q="ali abc" gives exact match and desired result.
>
> I want to do wildcard search where criteria can include spaces like
> example - "ahemad a* or ahemad a*
>
>
> i.e. if space is present then I am not able to to wildcard search.
>
> Is there any way by which wildcard search will be achieved even if space
> is present in token.
>
> The field type have is below:
>
>    <fieldType name="string_rev"class="solr.TextField"
> sortMissingLast="true">
>
>    <analyzer type="index">
>
>        <tokenizerclass="solr.KeywordTokenizerFactory"/>
>
>        <filterclass="solr.LowerCaseFilterFactory" />
>
>        <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
> replacement=""replace="all" />
>
>        <filterclass="solr.ReversedWildcardFilterFactory" />
>
>    </analyzer>
>
>    <analyzer type="query">
>
>        <tokenizerclass="solr.KeywordTokenizerFactory"/>
>
>        <filterclass="solr.LowerCaseFilterFactory" />
>
>        <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
> replacement=""replace="all" />
>
>    </analyzer>
>
> </fieldType>
> Any help would be great.
> Thanks,Ahemad Ali
 
Reply | Threaded
Open this post in threaded view
|

Re: wildcard search doesn't fetch results when field has whi

Erick Erickson
Yes. But You haven’t told us what _type_ of field you’re working with though. If it’s a “string” type, then ComplexPhraseQueryParser won’t work. Looking again at your example it looks as though you are using strings. Then try
abc\ d*

Adding debug=query to your url will show you how the query gets parsed and may help considerably.

Best,
Erick
 

> On Mar 31, 2019, at 7:24 AM, Ahemad Ali <[hidden email]> wrote:
>
> Erick,I tried complexqueryparser, still no result.Escape white space, do you mean to say using "\" ?Thanks,Ahemad
>
> Sent from Yahoo Mail on Android
>
>  On Sun, Mar 31, 2019 at 1:22, Erick Erickson<[hidden email]> wrote:   Try complexphrasequeryparser. If (and only if) you always want to search
> from the beginning of the content, you might be able to use string rather
> than text-based Fields but make sure to escape whitespace...
>
> Best,
> Erick
>
> On Sat, Mar 30, 2019, 10:33 [hidden email]
> <[hidden email]> wrote:
>
>> Hi ,
>> I have field with white spaces and special characters on which indexing
>> needs to be done to do wildcard querying.
>> It works for most of the scnearios with wildcard search.
>> e.g. if my data is "ali.abc" and "abc_pqr" and "ali abc" and "ahemad ali"
>> then search with ali* gives this three results.
>>
>> But I am not able to search with say -  ali a*
>>
>> Search with query q="ali abc" gives exact match and desired result.
>>
>> I want to do wildcard search where criteria can include spaces like
>> example - "ahemad a* or ahemad a*
>>
>>
>> i.e. if space is present then I am not able to to wildcard search.
>>
>> Is there any way by which wildcard search will be achieved even if space
>> is present in token.
>>
>> The field type have is below:
>>
>>     <fieldType name="string_rev"class="solr.TextField"
>> sortMissingLast="true">
>>
>>     <analyzer type="index">
>>
>>         <tokenizerclass="solr.KeywordTokenizerFactory"/>
>>
>>         <filterclass="solr.LowerCaseFilterFactory" />
>>
>>         <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
>> replacement=""replace="all" />
>>
>>         <filterclass="solr.ReversedWildcardFilterFactory" />
>>
>>     </analyzer>
>>
>>     <analyzer type="query">
>>
>>         <tokenizerclass="solr.KeywordTokenizerFactory"/>
>>
>>         <filterclass="solr.LowerCaseFilterFactory" />
>>
>>         <filterclass="solr.PatternReplaceFilterFactory"pattern="[\s+]"
>> replacement=""replace="all" />
>>
>>     </analyzer>
>>
>> </fieldType>
>> Any help would be great.
>> Thanks,Ahemad Ali
>