0
id: 1,
name: "Jean Pantalon",
title: null,
subtitle: null,
description: null,
tags: null,
seoUrl: null,
clickCounter: 0,
model: null,
sku: null,
ean: null,
displayPrice: 0,
price: 0,
isActive: true,
isDeleted: false,
productPhotos: null,
productCategories: [
  {
    id: 1,
    productId: 1,
    categoryId: 2,
    category: {
       id: 2,
       name: "Spor",
       topCategoryId: 0,
       subCategories: null
       }
    },
 ]

Hello everyone, elasticseaarch has such a json yield, I want to filter it, for example the name in the productCategories te category Sports ones, how can I write this query

I'm using the c # ta nest library

2
  • Nothing to do with C. Commented Aug 25, 2020 at 9:19
  • Can you add further information about how the index is represented in C#? Commented Aug 25, 2020 at 13:52

1 Answer 1

1

I don't know about how to do it in your lib, but in elasticsearch:

productCategories must be mapped with a "nested" data type. Then you will be able to construct a query like this:

GET /my-index/_search
{
  "query": {
    "nested": {
      "path": "productCategories",
      "query": {
        "bool": {
          "must": [
            { "match": { "productCategories.category.name": "sport" } }
          ]
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.