Partial facet matching

Hi,

I’m trying to do backend code (Go) behaving similarly as the city part of the autocomplete example here https://jsfiddle.net/RaphiD/z0t36t7o/.

I have an index which looks like this:

{
  "textField": "first name",
  "filter1": "my first filter1",
  "filter2": "my second filter1"
},
{
  "textField": "second name",
  "filter1": "my first filter2",
  "filter2": "my second filter1"
},
{
  "textField": "third name",
  "filter1": "my first filter1",
  "filter2": "my second filter2"
}

I want to be able to offer facets to the client with auto complete so that they can have an auto complete field for filter1 and filter2, and do free text search on textField but I can’t figure out how the above fiddle is doing the queries (or if it’s solved by multiple indices).

Say the user comes to an empty form. They start typing “my” on filter1, I then want to return

{
“my first filter1”: 2,
“my first filter2”: 1
}

Say they select “my first filter1” for filter1, and start typing “my” in filter2. I then want to give back:

{
“my second filter1”: 1,
“my second filter2”: 1
}

If they have any text in the textField input field that should also apply to the search. What I would’ve hoped would work was to set filter1 and filter2 as searchable facets in the gui and then do:

res, err := index.Search("",
opt.Filters("filter1:‘my’),
opt.Facets(“filter1”),
opt.ResponseFields(“facets”))

And then this for the second:

res, err := index.Search("",
opt.Filters("filter1:‘my first filter1’ AND filter2:‘my’’’),
opt.Facets(“filter2”),
opt.ResponseFields(“facets”))

This doesn’t work, as neither of them fully match the filter and I get an empty response. What would I need to do to get the above working?

The fiddle above, if I get it right, does just that for the city part of the autocomplete. If I start typing a country name will cities with a partial country match show up, and if I type in a city name it’s the same.

Hey there!

From what you’ve provided, it appears that you might be using filters to match partial attribute values. Please be sure that you are using filters to match entire attributes, as attempting to only match partial attributes values won’t work.