... what do i need to do here
# community-help
b
... what do i need to do here
j
You’d define your schema as:
Copy code
{
  "name": "test",
  "enable_nested_fields": true,
  "fields": [
    {
      "name": "customer_products.name",
      "facet": true,
      "type": "string[]"
    },
    {
      "name": "customer_products.customers",
      "facet": true,
      "type": "string[]"
    }
  ]
}
And then you’ll be able to search on those fields using the
q
and
query_by
parameters
b
those two things are separate now though
i need iphone-10 assocaited with tbv, and st
and iphone-11 associated with only st
j
You could use
filter_by= customer_products.customers:=st && customer_products.name:=iphone-11
That let’s you structure the query
b
ok
i'll give it a try
thanks
👍 1
Copy code
"document": {
                "customer_products": [
                    {
                        "customers": [
                            "tbv",
                            "st"
                        ],
                        "name": "iphone x",
                        "slug": "iphone-x"
                    },
                    {
                        "customers": [
                            "tbv"
                        ],
                        "name": "iphone 11",
                        "slug": "iphone-11"
                    }
                ],
                "id": "1",
                "title": "How do I reset my iphone?"
            },
            "highlight": {
                "full": {},
                "meta": {
                    "title": {
                        "matched_tokens": [
                            "iphone"
                        ]
                    }
                },
                "snippet": {
                    "title": "How do I reset my <mark>iphone</mark>?"
                }
            },
this should not return
because its iphone 11 belongs to customer TBV
thats what i'm saying about those nested fields are separate
i need association there somewhere
j
Ah I see what you mean…
You’d have to change your data structure to something like this to accomplish what you’re trying to do:
Copy code
[
  {
    "title": "How do I reset my iphone?",
    "name": "iphone x",
    "slug": "iphone-x",
    "customers": [
      "tbv",
      "st"
    ]
  },
  {
    "title": "How do I reset my iphone?",
    "name": "iphone 11",
    "slug": "iphone-11",
    "customers": [
      "tbv"
    ]
  },
  {
    "title": "How do I reset my Android?",
    "name": "samsung 123",
    "slug": "samsung-fold",
    "customers": [
      "tbv",
      "st"
    ]
  },
  {
    "title": "How do I reset my Android?",
    "name": "samsung 456",
    "slug": "samsung-456",
    "customers": [
      "tbv"
    ]
  }
]
b
got it so just duplicate the documents
should i do separate index?
j
If you’re only searching on those two fields, then a single index is good
b
yeah theres more
i'll split the indexes
by customer