nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.54k stars 492 forks source link

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

Closed MichaelRoger closed 2 years ago

MichaelRoger commented 2 years ago

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'}]}]

springuper commented 2 years ago

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

ts-thomas commented 2 years ago

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