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, <[email protected]> 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 [email protected].
> 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 [email protected].
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.