Open joepio opened 2 weeks ago
Nico tried setting zaakgegevens.zk-nummer
locally, but that did not seem to work.
So Meilisearch flattens nested structures, which should mean that we can search in it using the above method. I'm not sure what is going on.
There are other fields in the searchableAttributes
that are not actually searchable. I have not investigated all of them, but here are some results:
"naam", // toplevel
"id", // toplevel
"jaar", // nested, not searchable
"_geo", // toplevel, composed, searchable
"geo-EPSG28992", // nested, composed, not searchable
"bag-aob-id", // nested, searchable
"bag-aob-gebruiksdoel", // nested, array-valued, not searchable
"bag-aob-oppervlakte",
"bag-num-id", // nested, not searchable (?)
"bag-num-id-neven",
"bag-num-postcode", // nested, searchable (nested inside hoofdadres)
"bag-num-postcode-neven",
"bag-num-volledig", // nested, searchable (nested inside hoofdadres)
"bag-num-volledig-neven",
"bag-opr-id", // nested, searchable (nested inside hoofdadres)
"bag-opr-id-neven",
"bag-opr-naam",
"bag-opr-naam-neven",
"bag-opr-volledig",
"bag-pnd-geo",
"bag-pnd-geo-EPSG28992", // nested in array/object, not searchable
"bag-pnd-id", // nested in array/object, not searchable
"bag-pnd-oorspronkelijk-bouwjaar", // nested in array/object, not searchable
"bag-wpl-id",
"bag-wpl-id-neven",
"bag-wpl-naam",
"bag-wpl-naam-neven",
"bwk-wijknaam",
"bwk-subwijknaam",
"bwk-buurtnaam",
"bwk-subbuurtnaam",
"zk-nummer", // nested in array/object, not searchable
"locatie-aanduiding"
The non-searchable fields seem to have in common that they are inside an array or contain an array.
There are other fields in the searchableAttributes
that are not actually searchable. I checked this on the basis of a JSON record that was inserted into the Meili index.
I have not investigated all fields, but here are some results:
"naam", // toplevel
"id", // toplevel
"jaar", // nested, not searchable
"_geo", // toplevel, composed, searchable
"geo-EPSG28992", // nested, composed, not searchable
"bag-aob-id", // nested, searchable
"bag-aob-gebruiksdoel", // nested, array-valued, not searchable
"bag-aob-oppervlakte",
"bag-num-id", // nested, not searchable (?)
"bag-num-id-neven",
"bag-num-postcode", // nested, searchable (nested inside hoofdadres)
"bag-num-postcode-neven",
"bag-num-volledig", // nested, searchable (nested inside hoofdadres)
"bag-num-volledig-neven",
"bag-opr-id", // nested, searchable (nested inside hoofdadres)
"bag-opr-id-neven",
"bag-opr-naam",
"bag-opr-naam-neven",
"bag-opr-volledig",
"bag-pnd-geo",
"bag-pnd-geo-EPSG28992", // nested in array/object, not searchable
"bag-pnd-id", // nested in array/object, not searchable
"bag-pnd-oorspronkelijk-bouwjaar", // nested in array/object, not searchable
"bag-wpl-id",
"bag-wpl-id-neven",
"bag-wpl-naam",
"bag-wpl-naam-neven",
"bwk-wijknaam",
"bwk-subwijknaam",
"bwk-buurtnaam",
"bwk-subbuurtnaam",
"zk-nummer", // nested in array/object, not searchable
"locatie-aanduiding"
The non-searchable fields seem to have in common that they are inside an array or contain an array.
I tried searching in nested arrays and objects (see "nestedtest" index on blue), which seems to work fine. So meilisearch does allow searching in nested fields, but we still need to set searchableAttributes
in the correct way.
Just ran this test:
export async function importDemo() {
const altIndex = client.index("nestedtest");
altIndex.addDocuments([
{
id: "testedoc",
title: "TestDoc 1.",
arr: ["alpha"],
nested: {
title: "bravo",
arr: ["charlie"],
},
},
]);
await altIndex.updateSearchableAttributes(["nested.title", "nested.arr"]);
}
And I can find both charlie
and bravo
values. This tells me that the updateSearchableAttributes
syntax works as I thought: you can use the dot syntax.
@nverwer So it surprises me that settings zaakgegevens.zk-nummer
as a searchableAttribute does not work.
Conclusion: It is not clear what is wrong, and MeiliSearch does not provide an overview of the content of its indexes. Maybe we should switch to Solr, which is a much better search engine?
Customer wants to be able to search by zaaknummer (
zk-nummer
). We've added this to thesearchableAttributes
, but it does not work. This is probably because Meilisearch does not support searching in nested objects, at least not with this configuration.Two solutions:
searchableAttributes
and use dot-notation (mentioned in the feature requests).zk-nummer
to root object