F
F
Flyr1Q2015-07-05 14:11:23
elasticsearch
Flyr1Q, 2015-07-05 14:11:23

How to filter based on the number of nested objects?

I pass some_date and some_size as parameters to the search .
How to form a query for the filter so that only those articles are returned whose number of comments created before some_date was less than some_size
I have an Article and Comment model followed by mapping:

"mappings" : {
  "article" : {
    "properties" : {
      "comments" : {
        "type" : "nested",
        "properties" : {
          "date" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          }
        }
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
un1t, 2015-07-05
@un1t

Well, you can create a separate field that will be substituted during indexing.
Or use script filter
https://www.elastic.co/guide/en/elasticsearch/refe...
Here is a similar question, only about sorting.
stackoverflow.com/questions/19609498/elastic-searc...
P.Syu Curious to know why the comments inside the article needed to be written down?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question