skip to Main Content

then if we write a nested query to get brother then will we get the both occurences present in the array or json or only single occurence?

for example
if we are querying to get the word "brother" and its present more than twice in the array of json
will it show only one occurence of brother or multiple occurences?
hence we are handling multiple files we need the file id in which the word is present and if single word is present in a file more than once is it possible to get the word in that single file more than once?

i tried to get the single file id more than once because the single file contained the word more than once in multiple jsons but im getting the file id only once …

2

Answers


  1. Chosen as BEST ANSWER

    We have to use a for loop in any programming language and we will get only max 3 hits in inner hits. We have to access the json file and load it in Python for example and then use for loop and we can have upto 3 hits.by this process we can access upto 3 inner hits in a same file. the code:- we can fetch em in this way for i in range(some_value):

    try:
    
    
    
        uniq_id = data["hits"]["hits"][i]["_id"]
        start = data["hits"]["hits"][i]["inner_hits"]["key"]["hits"]["hits"][0]["fields"]["key.start"][0]
        check = data["hits"]["hits"][i]["inner_hits"]["key"]["hits"]["total"]["value"]
    

  2. If you are using kibana sql, you will search any occurence in each elasticsearch doc. If you search by "brother" you will get 1 occurence from each doc contains the word "brother". If you have 3 docs and once has 3 times the word you are searching for and the other 2 have the word once each, you will get 3 hits.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search