I'm using elasticsearch with the FOQElastica bundle in a PHP project and
it's been a few days I'm trying to make elasticsearch the way I want.
I would like to make two differents search, one which search the exact
terms in the query and another one which search query terms one by one. And
I don't want to just make one search and have both. I need to make two
differents search to treat data after that.
Here is an example:
If my search is 'conan and andy', the first result should come up with
Documents with the exact name 'conan and andy'
Documents with name containing 'conan and andy'
The second search with the same query should come up with:
Documents containing 'conan' or 'andy'
I think it is about mapping and custom analyzer but I don't know how to
figure this out.
Thank you for your help!
On a field level, this is quite easy - you just need to index the same
field twice using multi_fieldhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type/type. Search 1) would be term search against not_analyzed version, search
2) would be phrase search against analyzed version and search 3) would be
match search against analyze version. If you need to do it for all fields
in the document it's more complicated but possible. Could you tell us a
little bit more about your document structure?
On Thursday, April 18, 2013 10:23:41 AM UTC-4, Damien wrote:
Hello,
I'm using elasticsearch with the FOQElastica bundle in a PHP project and
it's been a few days I'm trying to make elasticsearch the way I want.
I would like to make two differents search, one which search the exact
terms in the query and another one which search query terms one by one. And
I don't want to just make one search and have both. I need to make two
differents search to treat data after that.
Here is an example:
If my search is 'conan and andy', the first result should come up with
Documents with the exact name 'conan and andy'
Documents with name containing 'conan and andy'
The second search with the same query should come up with:
Documents containing 'conan' or 'andy'
I think it is about mapping and custom analyzer but I don't know how to
figure this out.
Thank you for your help!
Thank you for your answer.
And yeah you're right, I found that few hours later after trying hard.
Well, I don't need multi_field, apparently phrase search is doing both 1)
and 2) so that is cool. And an anlyze version works too for 3)!
But now I have a problem to calculate a custom query score. I just made
another post, if you know few things in custom query too, some help would
be very appreciated! Here is my other post: https://groups.google.com/forum/?fromgroups=#!topic/elasticsearch/uII3y8ysn2I
Thanks.
Le jeudi 18 avril 2013 16:25:32 UTC-4, Igor Motov a écrit :
On a field level, this is quite easy - you just need to index the same
field twice using multi_fieldhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type/type. Search 1) would be term search against not_analyzed version, search
2) would be phrase search against analyzed version and search 3) would be
match search against analyze version. If you need to do it for all fields
in the document it's more complicated but possible. Could you tell us a
little bit more about your document structure?
On Thursday, April 18, 2013 10:23:41 AM UTC-4, Damien wrote:
Hello,
I'm using elasticsearch with the FOQElastica bundle in a PHP project and
it's been a few days I'm trying to make elasticsearch the way I want.
I would like to make two differents search, one which search the exact
terms in the query and another one which search query terms one by one. And
I don't want to just make one search and have both. I need to make two
differents search to treat data after that.
Here is an example:
If my search is 'conan and andy', the first result should come up with
Documents with the exact name 'conan and andy'
Documents with name containing 'conan and andy'
The second search with the same query should come up with:
Documents containing 'conan' or 'andy'
I think it is about mapping and custom analyzer but I don't know how to
figure this out.
Thank you for your help!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.