elasticsearch-rails

Yield/add search term to ElasticSearch results

情到浓时终转凉″ 提交于 2021-01-29 08:01:31
问题 I'm doing a ElasticSearch query with multiple terms constructed dynamically, so it looks like this: ... must: [ { terms: { tags_slug: ['term_a', 'term_b'] } }, ... ] ... everything works fine, but I'd like to add to each result, the term that it had match with, so, if for instance the result #1 matched term_a , I'd like somehow to be able to get that term from the current result, something like this: Model.search(...).results[0].matched_term # => 'term_a' Model.search(...).results[1].matched

Elasticsearch filter the maximum value document

家住魔仙堡 提交于 2020-01-02 10:27:14
问题 I trying to get the maximum value of document from the same name records. Forexample, I have 3 users, 2 of them have same name but different followers count, I wanted to return only 1 document from the 2 same with same name based on the maximum of followers_count. { id: 1, name: "John Greenwood", follower_count: 100 } { id: 2, name: "John Greenwood", follower_count: 200 } { id: 3, name: "John Underwood", follower_count: 300 } So the result would be, { id: 2, name: "John Greenwood", follower

ElasticSearch Nested Query - exclude parent document

∥☆過路亽.° 提交于 2019-12-11 02:27:52
问题 Trying to exclude top-level documents where one of the child documents doesn't match the query. For the example below, I'm trying to exclude all documents where one of its nested jobs has current: true , and matches with the company name: Elastic . But since one of the nested job documents matches with current: false and company name: Elastic , this document is returned. I am using a nested query with a must match on company name and a filter where current: false. How can I make it so that