Hi Nik, would a script field also work for that? Something like:
{ "script_fields": { "field_match1": { "script": "if(_index['field1']['searchterm'].tf() > 0){ return 1;} else {return 0;}" }, "field_match2": { "script": "if(_index['field2']['searchterm'].tf() > 0){ return 1;} else {return 0;}" }, .... } } Or did I get that wrong? On Fri, Feb 7, 2014 at 2:36 PM, Nikolas Everett <nik9...@gmail.com> wrote: > I was thinking of putting together a simple "highlighter" that just returns > if a field contains a match or not. This sounds like a nice logic extension > to that. It probably wouldn't actually be a "highlighter" but I imagine > it'd run during the highlight phase and function similarly. It'd need > something like the highlight_query, for example, to function properly. > Anyway, I believe the short answer is, if you are looking for something > specific, file an issue on github. > > Nik > > > On Fri, Feb 7, 2014 at 8:28 AM, Britta Weber > <britta.we...@elasticsearch.com> wrote: >> >> If you know the fields that are contained in the document, you could >> use a function_score query . For counting the number of fields a word >> is contained in, you can use function_score with a boost_factor like >> this: >> >> ``` >> { >> "query": { >> "function_score": { >> "functions": [ >> { >> "filter": { >> "term": { >> "field1": "searchterm" >> } >> }, >> "boost_factor": 1 >> }, >> { >> "filter": { >> "term": { >> "field2": "searchterm" >> } >> }, >> "boost_factor": 1 >> }, >> .... (here be more filters) >> ], >> "boost_mode": "replace", >> "score_mode": "sum" >> } >> } >> } >> ``` >> This will add 1 to the score for each field (field1, field2,... ) that >> has the term "searchterm" and the final score for each document will >> be the number of fields in the document containing the term. Is this >> what you want? >> >> For getting the term frequencies, you can checkout text scoring in scripts >> here: >> >> >> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-advanced-scripting.html >> >> See also this thread: >> >> https://groups.google.com/forum/#!msg/elasticsearch/9fOEN1uArIY/7bVZP22zYg8J >> >> Cheers, >> Britta >> >> On Fri, Feb 7, 2014 at 7:35 AM, <usha2...@gmail.com> wrote: >> > Hi, >> > >> > How do we implement whymatch concept in elasticsearch by finding the >> > total >> > number of fields in which the search term occurs and the frequency of >> > that >> > search term?? >> > >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "elasticsearch" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to elasticsearch+unsubscr...@googlegroups.com. >> > To view this discussion on the web visit >> > >> > https://groups.google.com/d/msgid/elasticsearch/72b99acc-bd1e-4954-bc52-f09971397daf%40googlegroups.com. >> > For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elasticsearch" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elasticsearch+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/CALhJbBji5u0oQxJB3Te-k4wKZ108pbn4an5kk%2BDDbjxB4%2BWJnQ%40mail.gmail.com. >> >> For more options, visit https://groups.google.com/groups/opt_out. > > > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elasticsearch+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/CAPmjWd06gQg-RDGHaD4ScWzLRshUQ6NBybHfTnD1ufDUUH_CMA%40mail.gmail.com. > > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALhJbBhGmNn2EQWuxPeoAq2Do%3DgoZSZdYKTDLy2FkW1y1YkZZg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.