Как написать запрос NEST Elasticsearch, в котором дочерние термины принадлежат определенному c родителю - PullRequest
0 голосов
/ 11 июля 2020

Я проиндексировал следующие документы в Elasticsearch (версия 7.8), как показано ниже:

[
  {
    ... //other properties
    "itemId": 1,
    "location": {
      "suburb": "suburb 1",
      "state": "state A"
    }
    ... //other properties
  },
  {
    ... //other properties
    "itemId": 2,
    "location": {
      "suburb": "suburb 2",
      "state": "state A"
    }
    ... //other properties
  },
  {
    ... //other properties
    "itemId": 3,
    "location": {
      "suburb": "suburb 3",
      "state": "state A"
    }
    ... //other properties
  },
  {
    ... //other properties
    "itemId": 4,
    "location": {
      "suburb": "suburb 4",
      "state": "state B"
    }
    ... //other properties
  },
  {
    ... //other properties
    "itemId": 5,
    "location": {
      "suburb": "suburb 5",
      "state": "state B"
    }
    ... //other properties
  },
  {
    ... //other properties
    "itemId": 6,
    "location": {
      "suburb": "suburb 6",
      "state": "state B"
    }
    ... //other properties
  }
]

Учитывая следующий поисковый запрос:

Dictionary<string, HashSet<string>> location = new Dictionary<string, HashSet<string>>
            {
                {"state A", new HashSet<string>(){"suburb 1", "suburb 2"} },
                {"state B", new HashSet<string>(){"suburb 5"} }
            };

Мне нужно написать поисковый запрос местоположения использование NEST для возврата элементов, соответствующих вышеуказанному запросу. Поэтому я ожидаю, что товары 1, 2 и 5 будут возвращены. Спасибо.

...