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 Rajvinder Pal <ra...@gmail.com> on 2018/03/06 09:55:43 UTC

Need a Query syntax for fetching results

Hi ,
I am new to Lucene. I have a requirement where when i request the
organization name, it should show the matching organization names.

I have written the q param as

orgname_text: ABC test

it is returning the result :-

ABC test limited
ABC XYZ limited
DEF ABC limted
test limited

I want all the matching result which starts  with either ABC or test. so
here i dont want DEF ABC limited. Please let me know what feature or
syntax  i should use to get the required result.

Thanks
Raj

Re: Need a Query syntax for fetching results

Posted by Rick Leir <rl...@leirtech.com>.
Hi Raj
Maybe this would be what you need.
"Keyword Tokenizer
This tokenizer treats the entire text field as a single token."
There used to be an example showing the use of this in schema.xml, but I am away from my computer so it is hard to check.
And everything Emir says is spot-on.
Then you might want to go further with ngrams or a spelling check so the user need not be perfect.
Cheers -- Rick


On March 6, 2018 5:40:02 AM EST, "Emir Arnautović" <em...@sematext.com> wrote:
>Hi Raj,
>You need to get familiar with Solr analysis chain:
>https://lucene.apache.org/solr/guide/6_6/understanding-analyzers-tokenizers-and-filters.html
><https://lucene.apache.org/solr/guide/6_6/understanding-analyzers-tokenizers-and-filters.html>
>
>When playing with it, use admin console analysis tab to see what tokens
>are produced.
>
>And you need to understand your search requirements and cover them with
>one or more fields. Note that you can use copyField to index the same
>content in different ways to handle different search requirements.
>
>It is probably not what you want, but based on what you described, you
>do not care about anything but the first token in your field, so you
>can use LimitTokenCountFilter to index only the first token. In query
>analysis you do not use it and with default operator OR you will get
>what you want.
>
>HTH,
>Emir
>--
>Monitoring - Log Management - Alerting - Anomaly Detection
>Solr & Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
>> On 6 Mar 2018, at 10:55, Rajvinder Pal <ra...@gmail.com>
>wrote:
>> 
>> Hi ,
>> I am new to Lucene. I have a requirement where when i request the
>> organization name, it should show the matching organization names.
>> 
>> I have written the q param as
>> 
>> orgname_text: ABC test
>> 
>> it is returning the result :-
>> 
>> ABC test limited
>> ABC XYZ limited
>> DEF ABC limted
>> test limited
>> 
>> I want all the matching result which starts  with either ABC or test.
>so
>> here i dont want DEF ABC limited. Please let me know what feature or
>> syntax  i should use to get the required result.
>> 
>> Thanks
>> Raj

-- 
Sorry for being brief. Alternate email is rickleir at yahoo dot com 

Re: Need a Query syntax for fetching results

Posted by Emir Arnautović <em...@sematext.com>.
Hi Raj,
You need to get familiar with Solr analysis chain: https://lucene.apache.org/solr/guide/6_6/understanding-analyzers-tokenizers-and-filters.html <https://lucene.apache.org/solr/guide/6_6/understanding-analyzers-tokenizers-and-filters.html>

When playing with it, use admin console analysis tab to see what tokens are produced.

And you need to understand your search requirements and cover them with one or more fields. Note that you can use copyField to index the same content in different ways to handle different search requirements.

It is probably not what you want, but based on what you described, you do not care about anything but the first token in your field, so you can use LimitTokenCountFilter to index only the first token. In query analysis you do not use it and with default operator OR you will get what you want.

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 6 Mar 2018, at 10:55, Rajvinder Pal <ra...@gmail.com> wrote:
> 
> Hi ,
> I am new to Lucene. I have a requirement where when i request the
> organization name, it should show the matching organization names.
> 
> I have written the q param as
> 
> orgname_text: ABC test
> 
> it is returning the result :-
> 
> ABC test limited
> ABC XYZ limited
> DEF ABC limted
> test limited
> 
> I want all the matching result which starts  with either ABC or test. so
> here i dont want DEF ABC limited. Please let me know what feature or
> syntax  i should use to get the required result.
> 
> Thanks
> Raj