GreenInfo-Network / seattle-building-dashboard

Energy benchmarking for Seattle
https://greeninfo-network.github.io/seattle-building-dashboard/
ISC License
1 stars 0 forks source link

Search issues #65

Closed tomay closed 10 months ago

tomay commented 10 months ago

Mike reported that search works for exact terms, but not substring matches

For example, searching on "Marriott" turns up two results:

image

But if I then search on "Convention", that doesn't pick up "Marriott Residence Inn Convention" at all as you would expect:

image

tomay commented 10 months ago

The underlying search is handled by Fuse.js, with options passed in from seattle.json

tomay commented 10 months ago

I also just noticed this:

image

Which indicates it might be doing some kind of a conditional proximity search? When does that come into play?

So we'd want to take that into account before tweaking the Fuse options to just "fix it" for the one reported issue

tomay commented 10 months ago

An additional clue, the Autocomplete library is this: https://github.com/Pixabay/JavaScript-autoComplete

Of course this is ancient, and the demo and documentation website is defunct

tomay commented 10 months ago

From this it looks like "autocomplete" is initially on and responding to keyup, and that uses Fuse to search building data.

But if you hit the enter key, it does an address search using the entered term and the search URL specified in seattle.json (in this case, Nominatim)

CfyUybtfom

In code here: https://github.com/GreenInfo-Network/seattle-building-dashboard/blob/master/src/lib/autocomplete/autocomplete.js#L188-L203

tomay commented 10 months ago

This is very helpful:

Modified the example using settings from seattle.json we have:

        "location": 0
        "distance": 50
        "threshold": 0.1

With the above options, for something to be considered a match, it would have to be within (threshold) 0.1 x (distance) 50 = 5 characters away from the expected location 0.

That's never going to match a word near the end of a long string, e.g. "Marriott Residence Inn Convention Center". I think that's 23 characters away

If I change to the following:

        "location": 0,
        "distance": 80,
        "threshold": 0.3,

I do get the result, although it is a good ways down the list of suggestions. At the bottom in fact. Is there some way to give exact matches a higher rank?

image

tomay commented 10 months ago

I'm going to stick with these values for now and see what the client thinks of the results