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 Mahmoud Almokadem <pr...@gmail.com> on 2016/09/21 06:06:36 UTC
Search with the start of field
Hello,
What is the best way to search with the start token of field?
For example: the field contains these values
Document1: ABC DEF GHI
Document2: DEF GHI JKL
when I search with DEF, I want to get Document2 only. Is that possible?
Thanks,
Mahmoud
Re: Search with the start of field
Posted by William Bell <bi...@gmail.com>.
Show us the FieldType and Field definitions.
On Wed, Sep 21, 2016 at 12:06 AM, Mahmoud Almokadem <pr...@gmail.com>
wrote:
> Hello,
>
> What is the best way to search with the start token of field?
>
> For example: the field contains these values
>
> Document1: ABC DEF GHI
> Document2: DEF GHI JKL
>
> when I search with DEF, I want to get Document2 only. Is that possible?
>
> Thanks,
> Mahmoud
>
>
--
Bill Bell
billnbell@gmail.com
cell 720-256-8076
Re: Search with the start of field
Posted by Jan Høydahl <ja...@cominvent.com>.
You could do a hack with the field type similar to this text_lower_exact type: https://github.com/cominvent/exactmatch/blob/master/conf/schema.xml <https://github.com/cominvent/exactmatch/blob/master/conf/schema.xml>
But if you only do the hack on the “index” side of analysis, you are free to do phrase searches like “ǣ DEF” which would only match the beginning since you include the very first token in the phrase.
It is not a perfect solution, and I’d like a native query operator to handle it, but so far we have not got one.
You may also try regex query, like myfield:/^DEF/
--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com
> 21. sep. 2016 kl. 08.06 skrev Mahmoud Almokadem <pr...@gmail.com>:
>
> Hello,
>
> What is the best way to search with the start token of field?
>
> For example: the field contains these values
>
> Document1: ABC DEF GHI
> Document2: DEF GHI JKL
>
> when I search with DEF, I want to get Document2 only. Is that possible?
>
> Thanks,
> Mahmoud
>
Re: Search with the start of field
Posted by Mikhail Khludnev <mk...@apache.org>.
You can experiment with {!xmlparser}<SpanFirst>.. see
https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-XMLQueryParser
On Wed, Sep 21, 2016 at 9:06 AM, Mahmoud Almokadem <pr...@gmail.com>
wrote:
> Hello,
>
> What is the best way to search with the start token of field?
>
> For example: the field contains these values
>
> Document1: ABC DEF GHI
> Document2: DEF GHI JKL
>
> when I search with DEF, I want to get Document2 only. Is that possible?
>
> Thanks,
> Mahmoud
>
>
--
Sincerely yours
Mikhail Khludnev