react-elasticsearch icon indicating copy to clipboard operation
react-elasticsearch copied to clipboard

nested set elastic search via nestedPath="tags"

Open insekticid opened this issue 4 years ago • 2 comments

<Facet id="tags" fields={["tags.name"]} nestedPath="tags" filterValueModifier={caseInsensitiveSearch}/>

nested

{
   "preference":"tags"
}{
   "query":{
      "bool":{
         "must":[
            {
               "bool":{
                  "should":[
                     
                  ]
               }
            },
            {
               "bool":{
                  "should":[
                     
                  ]
               }
            },
            {
               "multi_match":{
                  "query":"hamburger",
                  "type":"phrase",
                  "fields":[
                     "name"
                  ]
               }
            }
         ]
      }
   },
   "size":0,
   "aggs":{
      "tags.name":{
         "nested":{
            "path":"tags"
         },
         "aggs":{
            "tags.name":{
               "terms":{
                  "field":"tags.name",
                  "order":{
                     "_count":"desc"
                  },
                  "size":10
               }
            }
         }
      }
   },
   "track_total_hits":true
}

image

image

insekticid avatar Feb 17 '21 08:02 insekticid

Hi @insekticid 👋 Thank you for your contribution 🙏 . Could you explain briefly what problem it solves (i.e: why you added this). it will help me in testing and hopefully, validate it and merge it.

rap2hpoutre avatar Mar 02 '21 12:03 rap2hpoutre

you can use aggregate filter with subarray key like tags.name, it is not possible without nested

"_source" : {
             "name" : "Super article",
             "tags" : [
                {
                  "name" : "Top dnešní recepty",
                  "url" : "https://www.recepty.eu/top/",
                  "hashtag" : "TopDnes"
                },
                {
                  "name" : "Top týdenní recepty",
                  "url" : "https://www.recepty.eu/top/",
                  "hashtag" : "TopTýden"
                },
                {
                  "name" : "Top měsíční recepty",
                  "url" : "https://www.recepty.eu/top/",
                  "hashtag" : "TopMěsíc"
                },
                {
                  "name" : "Top recepty za rok",
                  "url" : "https://www.recepty.eu/top/",
                  "hashtag" : "TopRok"
                }
              ],

insekticid avatar Mar 03 '21 07:03 insekticid