coherenza / gebouwenpaspoort-webui

Zoekapplicatie met kaartweergave om gebouwen en adressen te bekijken. Combineert BAG, PDOK, Squit en meer data. In opdracht voor de Gemeente Utrecht
https://gebouwenpaspoort.pandata.nl
1 stars 1 forks source link

Search by zaaknummer #15

Open joepio opened 2 weeks ago

joepio commented 2 weeks ago

Customer wants to be able to search by zaaknummer (zk-nummer). We've added this to the searchableAttributes, 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:

joepio commented 2 weeks ago

Nico tried setting zaakgegevens.zk-nummer locally, but that did not seem to work.

joepio commented 2 weeks ago

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.

nverwer commented 2 weeks ago

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.

nverwer commented 2 weeks ago

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.

joepio commented 3 days ago

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.

joepio commented 21 hours ago

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.

nverwer commented 2 hours ago

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?