wildlifetrusts / nextdoornature

https://team-wilder-proto.pages.dev/
2 stars 1 forks source link

Improve free text search #8

Closed aaaaargZombies closed 1 year ago

aaaaargZombies commented 1 year ago

Acceptance Criteria

Implementation Notes

Elasticlunr

http://elasticlunr.com/

from the getting started …

var index = elasticlunr(function () {
    this.addField('title');
    this.addField('body');
    this.setRef('id');
});

var doc1 = {
    "id": 1,
    "title": "Oracle released its latest database Oracle 12g",
    "body": "Yestaday Oracle has released its new database Oracle 12g, this would make more money for this company and lead to a nice profit report of annual year."
}

var doc2 = {
    "id": 2,
    "title": "Oracle released its profit report of 2015",
    "body": "As expected, Oracle released its profit report of 2015, during the good sales of database and hardware, Oracle's profit of 2015 reached 12.5 Billion."
}

index.addDoc(doc1);
index.addDoc(doc2);

If all the json has uniform fields this will probably work nicely

some elm packages that do search

Fuse (probably the better option?)

https://fusejs.io/

Looks to be more actively maintained than elasticlunr

Search-index

https://github.com/fergiemcdowall/search-index

External JS in Elm

Ports

Web component

Examples

aaaaargZombies commented 1 year ago

By default elasticlunr is configured to work with english. There are some other language options available here

But no welsh, this means we should think particularly about stop words we need.

katjam commented 1 year ago

Oh that's very annoying about the Welsh.

In the first instance we maybe hide the search form if Welsh is toggled on?

aaaaargZombies commented 1 year ago

I've been looking at alternatives and honestly nothing looks like it's going to have purpose built welsh support. I guess shouldn't be a surprise if so much software isn't even built for huge languages like chinese or spanish.

aaaaargZombies commented 1 year ago

A useful comparison/demo of JS search options https://github.com/fiatjaf/search-comparison

Lunr based looks to be stricter, fuse is more fuzzy. which might be good for people who can't spell plant/animal names perfectly but might also produce more irrelevant results.

aaaaargZombies commented 1 year ago

questionably named http://www.gaddafipsum.com/ provides welsh gibberish, though it might be better to find some real welsh writing to test with.

kimadactyl commented 1 year ago

Worth asking the discord for suggestions here?

aaaaargZombies commented 1 year ago

welsh sample text options

katjam commented 1 year ago

@aaaaargZombies Is any of this ready to merge?

katjam commented 1 year ago

@aaaaargZombies I was attempting to verify this as: image

I re-jigged your AC into criteria + plan and have come to think that AC you left un-ticked didn't happen.

I'm not marking this as verified because I think the list returned is not always a very good match, so am wondering if we need to look into this a little more? I've not dug very deep, but for example https://team-wilder-proto.pages.dev/guides/making-sure-everyone-can-access-your-group-or-project comes up in a search for climate and this comes up in a search for woody https://www.wildlifetrusts.org/actions/reduce-food-waste.

I fee like we should think about improvements to search in the next cycle, but wanted you to verify first what the intent is as it is now. So if you can remember what you think you had working, update the AC here and we can verify as a baseline.

r-ferrier commented 1 year ago

Some more intel on this from discord:

hey all, you can adjust that here https://fusejs.io/api/options.html#distance I left the default. also if it finds no options it doesn't filter but maybe that's misleading...

now the plumbings in place it will probably be a quick fix to switch search libraries, I went for this one based on npm downloads, most recent code contributions and eyeballing the results on the live test I listed in the issue

aaaaargZombies commented 1 year ago

@undividual I have this to implement

There is some indication of what has been searched for (e.g. text at the top of the page)

Do you have any suggestions about how you'd like it to look. I was thinking of just adding a little subtitle below guides that says something like

Filtering on: XXXX showing NNN guides

We could update the actual guides title to be like

NN Guides on XXX

where X = query string and N = num guides

aaaaargZombies commented 1 year ago

search accessibility

https://technology.blog.gov.uk/2014/08/14/improving-accessibility-on-gov-uk-search/

aaaaargZombies commented 1 year ago
  • [ ] Search happens when I click submit (arrow? + text)

removed based on conversation in meeting today

aaaaargZombies commented 1 year ago

Search results are ordered based on how close of a match they are

resulting JSON is in order, in elm it is displaying in alphabetical order of title