Combine restrictSearchableAttributes with other filters in deconstructed records

I have a “products” index and each record can have up to 56 attributes. I decided to split each product record into 3 as there record size was too big and unmanageable.

My current records example for the same product with 3 product records in Products Index:

{
productId: 12345,
brand: ‘Nike’,
collection: ‘TOTO’
}

{
productId: 12345,
claimsA: ‘A long long long long text’
}

{
productId: 12345,
claimsB: ‘A different long long long long text’
}

I have a custom widget that allows user to restrict their search to a specific attribute (restrictSearchableAttribute).
My issue is that not 1 record has all of the attributes that are possible to filter on. So when a user searches keyword “long text” combined with facet "brand: ‘Nike’ " & select to restrictSearchableAttribute: [“claimsA”,“claimsB” ], they will get 0 results.

Is there a way to combine these filter options to make sure all the relevant products are returned?
I am open to suggestions of a better way to design my indexes i.e I could make a separate claims index, but I do not know how to perform a multi-index search using the instantsearch ui.

Hi @tahira,

Thank you for your example. Indeed, that is not exactly how we would have envisioned the use of “breaking up records” together with the use of distinct. It is interesting to hear that you have a record with 56 attributes and it is so large that it is exceeding the record size limits.

Can you post one example of your full record structure? The key is that we always recommend only indexing those attributes required for search - perhaps some is metadata and not required to be indexed (can just be in your database)?

Hi @ajay.david,

Here’s a example of a typical product record. we use 27 of the attributes for faceting & an additional 6 are searchable attributes.

// Record 1 is the main product record with all the attributes

{
“productId”: “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“name”: “Bain apaisant”,
“areas”: [
“Corps”
],
“typeSkins”: [
“typeSkins1”
],
“targets”: [
“target1”,
“target2”,
“target3”
],
“typePacks”: [
“pack1”
],
“packageCapacities”: [
“250 mL”
],
“distributionChannels”: [
“channel1”
],
“themes”: [
“theme1”
],
“ingredients”: [
“ingredient1”,
“ingredient2”,
“ingredient3”
],
“parentSegmentation”: [
“Youth / Class”
],
“subSegmentation”: ,
“brandName”: “TOTO”,
“collectionName”: “TELE”,
“categoryName”: “sunny”,
“typeName”: “Cosmétique”,
“tinted”: false,
“madeInFrance”: true,
“textureName”: “Huile”,
“spf”: null,
“specificMention”: “logo “nuit calme””,
“linkWebsite”: “https://www.testlink.com”,
“productSalesRevenue”: null,
“countryDistribution”: “FR”,
“archived”: false,
“commercialized”: true,
“mother”: null,
“perfume”: true,
“perfumeClaimed”: false,
“innovation”: false,
“uva”: null,
“dateOfArchived”: null,
“texturothequeName”: “Gel”,
“mainPhoto”: “https://test-link.com/dcc4aa0ecfc772703aff92e7776ea135.jpeg”,
“photos”: ,
“patents”: ,
“relatedINCI”: [
“INCI1”,
“INCI2”,
“INCI3”
],
“listINCI”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”,
“commentCip”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.”,
“proof”: “”,
“price”: null,
“priceLiter”: null,
“revindication”: “”,
“bio”: false,
“manual”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”,
“dateCommercialized”: “2009-01-01T00:00:00+00:00”,
“commentRd”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.”,
“roles”: [
“role1”,
“role2”,
“role3”,
“role4”
],
“isNow”: false,
“hasCommentCIP”: true,
“verbatimConso”: [
“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”
],
“hasINCI”: true,
“hasClaims”: true
}


// Record 2 for the same product is for the “claimsEfficiency” attribute. This is a searchable attribute

{
“productId”: “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“name”: “Bain apaisant”,
“brandName”: “TOTO”,
“collectionName”: “TELE”,
“claimsEfficiency”: {
“efficiency_primary_pack_front”: null,
“efficiency_primary_pack_back”: null,
“efficiency_secondary_pack_front”: “Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Malesuada bibendum arcu vitae elementum. Aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin.”,
“efficiency_secondary_pack_back”: null,
“efficiency_on_brand_website”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Egestas diam in arcu cursus euismod. Facilisi morbi tempus iaculis urna id volutpat lacus laoreet non. Sed nisi lacus sed viverra tellus in hac habitasse platea. Sed felis eget velit aliquet sagittis id. Viverra accumsan in nisl nisi scelerisque. Aliquam vestibulum morbi blandit cursus risus at ultrices. Eu mi bibendum neque egestas congue quisque egestas diam in. Nisi porta lorem mollis aliquam ut porttitor. Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Malesuada bibendum arcu vitae elementum. Aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin. Risus feugiat in ante metus dictum at tempor. Morbi tristique senectus et netus et malesuada fames. Quam vulputate dignissim suspendisse in est ante in nibh mauris. Varius morbi enim nunc faucibus a pellentesque sit amet. Sit amet consectetur adipiscing elit ut aliquam purus sit amet.
Scelerisque varius morbi enim nunc faucibus a. Mauris nunc congue nisi vitae suscipit tellus mauris a. Viverra aliquet eget sit amet tellus cras adipiscing enim. Neque convallis a cras semper auctor. At elementum eu facilisis sed. Condimentum id venenatis a condimentum vitae sapien pellentesque. Vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt. Blandit libero volutpat sed cras ornare arcu dui vivamus arcu. Sit amet aliquam id diam maecenas ultricies mi eget. Nulla porttitor massa id neque aliquam. Hendrerit dolor magna eget est lorem. Turpis tincidunt id aliquet risus feugiat in ante metus dictum.”,
“efficiency_on_other_source”: null
}}


// Record 3 for the same product is for the “claimsSecurity” attribute. This is a searchable attribute

{
“productId”: “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“name”: “Bain apaisant”,
“brandName”: “TOTO”,
“collectionName”: “TELE”,
“claimsSecurity”: {
“security_primary_pack_front”: "“Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Malesuada bibendum arcu vitae elementum. Aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin.”,
“security_primary_pack_back”: null,
“security_on_brand_website”: “Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Egestas diam in arcu cursus euismod. Facilisi morbi tempus iaculis urna id volutpat lacus laoreet non. Sed nisi lacus sed viverra tellus in hac habitasse platea. Sed felis eget velit aliquet sagittis id. Viverra accumsan in nisl nisi scelerisque. Aliquam vestibulum morbi blandit cursus risus at ultrices. Eu mi bibendum neque egestas congue quisque egestas diam in. Nisi porta lorem mollis aliquam ut porttitor. Vel quam elementum pulvinar etiam non quam lacus suspendisse faucibus. Malesuada bibendum arcu vitae elementum. Aenean euismod elementum nisi quis eleifend quam adipiscing vitae proin. Risus feugiat in ante metus dictum at tempor. Morbi tristique senectus et netus et malesuada fames. Quam vulputate dignissim suspendisse in est ante in nibh mauris. Varius morbi enim nunc faucibus a pellentesque sit amet. Sit amet consectetur adipiscing elit ut aliquam purus sit amet.
Scelerisque varius morbi enim nunc faucibus a. Mauris nunc congue nisi vitae suscipit tellus mauris a. Viverra aliquet eget sit amet tellus cras adipiscing enim. Neque convallis a cras semper auctor. At elementum eu facilisis sed. Condimentum id venenatis a condimentum vitae sapien pellentesque. Vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt. Blandit libero volutpat sed cras ornare arcu dui vivamus arcu. Sit amet aliquam id diam maecenas ultricies mi eget. Nulla porttitor massa id neque aliquam. Hendrerit dolor magna eget est lorem. Turpis tincidunt id aliquet risus feugiat in ante metus dictum.”,
“security_secondary_pack_front”: null,
“security_secondary_pack_back”: null,
“security_on_other_source”: “et tellus cras adipiscing enim. Neque convallis a cras semper auctor. At elementum eu facilisis sed. Condimentum id venenatis a condimentum vitae sapien pellentesque. Vulputate mi sit amet mauris commodo quis imperdiet massa tincidunt. Blandit libero volutpat sed cras ornare arcu dui vivamus arcu. Sit amet aliquam id diam mae”
}}

Hi @tahira,

To the extent you truly are limited by the record size and need to keep the records broken, then my recommendation for returning all records would be to send the same query to multiple indices, ensuring you get all relevant results:

Hi @ajay.david,

Thanks for the documentation link.
I’m not sure that you understood my problem however.
From what I understand in the documentation for multi-index querying, I will be sending the same query across various indices which would result in the same problem.
Params: {
query: “toto”,
facetFilter: [“theme”: “testTheme”]
}

ProductIndex: has 1 product with theme “testTheme” match

The request to ProductIndex would return 0 hits because it does not match the query “toto”

ClaimsIndex: has 1 claim that matches query “toto”

The request to ClaimsIndex would return 0 hits because it does not have the “theme” attribute & therefore no match to facetFilter: [“theme”: “testTheme”]

Please correct me if I have misunderstood.

Thanks,

Tahira

Hi @tahira,

Apologies if I provided a related method, but it did not encompass the exact need. In the alternative, an API request you could make is the "Multiple Queries". Using this method you can:

  • send 1 API request
  • target multiple indices
  • each can have it’s own query with it’s own parameters (i.e., different filters for each)