flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

am i not smart enough? how can i get a scored result for mutliple fields

Open MichaelRoger opened this issue 2 years ago • 1 comments

hi, when using documents with multiple fields, then my goal is to have a final result with a scoring based on the searchresult.

at the moment i would get just an array per field and no scoring information.

for example:

let index = new Document({
        document: {
            id: 'gid',
            index: [
                'givenNameReal',
                'surnameReal',
                'mainTasks'
            ]
        }
    });

let people = [{gid:1,givenNameReal:'Michael',surnameReal:'Mustermann',mainTasks:'something'},{gid:2,givenNameReal:'Hans',surnameReal:'Franz',mainTasks:'mustering else'}];

people.forEach((person: any) => {
            index.add(
                person);
        });
let result = this.index.search('Mich Muster');

so the result should be something like this:

[{gid:1,score:'0.8',findings:[{field:'givenNameReal',term:'Mich'},{field:'surnameReal',term:'Muster'}]}, {gid:2,score:'0.01',findings:[{field:'mainTasks',term:'Muster'}]}]

MichaelRoger avatar Apr 20 '22 08:04 MichaelRoger

I'm looking forward to the same thing, like Fuse.js https://fusejs.io/api/options.html#includescore

springuper avatar Apr 22 '22 03:04 springuper

Sorry no score documented, no score available, the score value is just calculated in the background and is applied to the order of results.

ts-thomas avatar Oct 02 '22 14:10 ts-thomas