0

We use enterprise search indexes to store items that can be tagged by multiple tenants. e.g

[
  {
    "id": 1,
    "name": "document 1",
    "tags": [
      { "company_id": 1, "tag_id": 1, "tag_name": "bla" },
      { "company_id": 2, "tag_id": 1, "tag_name": "bla" }
    ]
  }
]

I'm looking to find a way to retrieve all documents with only the tags of company 1

This request:

{
  "query": "",
  "facets": {
    "tags": {
      "type": "value"
    }
  },
  "sort": {
    "created": "desc"
  },
  "page": {
    "size": 20,
    "current": 1
  }
}

Is coming back with

...
    "facets": {
        "tags": [
            {
                "type": "value",
                "data": [
                    {
                        "value": "{\"company_id\":1,\"tag_id\":1,\"tag_name\":\"bla\"}",
                        "count": 1
                    },
                    {
                        "value": "{\"company_id\":2,\"tag_id\":1,\"tag_name\":\"bla\"}",
                        "count": 1
                    }
                ]
            }
        ],
}
...

Can I modify the request in a way such that I get no tags by "company_id" = 2 ?

I have a solution that involves modifying the results to strip the extra data after they are retrieved but I'm looking for a better solution.

Gerardo Sabetta
  • 371
  • 3
  • 12
  • What's the aim of your query? Do you just want to filter documents by company_id? Do you want to count the number of documents with company_id=1 and a specific couple of ? – Seasers Jan 02 '23 at 11:47
  • Could you also share your index mapping? – Seasers Jan 02 '23 at 12:26

0 Answers0