lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.67k stars 133 forks source link

Is fields option supported by query tree nodes? #199

Closed mastercoms closed 1 year ago

mastercoms commented 1 year ago

I was wondering because it doesn't seem like it's working for me. I'm trying to implement search syntax within specific fields for the user. Wanted to isolate the problem.

lucaong commented 1 year ago

Hi @mastercoms , yes, the fields search option should work with query expression trees too:

const ms = new MiniSearch({ fields: ['title', 'author', 'text'] })

let docs = [
 { id: 1, title: 'Let It Be', author: 'The Beatles', text: 'When I find myself in times of...' },
 { id: 2, title: 'Do I Wanna Know?', author: 'Arctic Monkeys', text: 'Have you got color in...' },
 { id: 3, title: 'The Times are A-Changing', author: 'Bob Dylan', text: 'Come gather round people...' },
 { id: 4, title: 'One Love (People get Ready)', author: 'Bob Marley', text: 'One love, one heart...' },
]

ms.addAll(docs)

// Simple example, "people" is in the text of document 3 and in the title of document 4,
// but we restrict the search to the title field:
ms.search({ fields: ['title'], queries: ['people'] })
// => [{ id: 4, ...}]

// The query above is identical to:
ms.search('people', { fields: ['title'] })

// More interesting example with deeper query expression tree:
ms.search({
 queries: [
   { fields: ['title'], queries: ['times'] },
   { fields: ['author'], queries: ['arctic'] }
 ]
})
// => [{ id: 2, ... }, { id: 3, ... }]

// Another example, where both subqueries have results, but no document satisfies both,
// so combining with AND yields no result:
ms.search({
  queries: [
    { fields: ['title'], queries: ['people'] },
    { fields: ['text'], queries: ['people'] }
  ],
  combineWith: 'AND'
})
// => []

// Contrast it with the following query, which instead yields two results:
ms.search('people', { fields: ['title', 'text'], combineWith: 'AND' })
// => [{ id: 3, ... }, { id: 4, ... }]

Do you have a specific example where this does not work? If you can provide an example to reproduce the problem I will look into it.

mastercoms commented 1 year ago

Ok, thank you for the response! Maybe I'm just being confused by the score? Is it that results have to match at least each node somewhat, or does each node contribute to a score? I'm currently getting cases where it does work in a lot of cases but then there's a few cases where results are getting in that don't match the entire tree.

And how could I demonstrate this happening properly? Would it work to provide the document JSON link and the query object?

lucaong commented 1 year ago

Hi @mastercoms , by default, unless you specify the combineWith option, different subqueries are combined with OR. Therefore, by default, you will get results for each document that matches at least one subquery, but those that match more than one subquery will generally score higher. This maximizes recall (which proportion of the relevant documents are returned), at the expense of precision (which proportion of the returned documents are relevant). Since scoring should sort better matches first, this is often a good default approach.

If you instead specify combineWith: 'AND' at the root, or in the parent of the nodes you have to combine, then the subqueries will be combined with AND: the results will only include the documents that match all subqueries, and any document that does not match even just a part of the tree will be omitted. With AND you get higher precision at the expense of recall. Depending on the use case, you might prefer one or the other.

Note that the value of an option is inherited by all sub trees, unless the sub tree specifies a different value for the same option. Therefore, if you specify combineWith: 'AND' at the root, you are basically changing the default for the whole tree (which is often what you want).

Examples

Referring to the same data as my comment above, this finds all documents that contain "people" in the title field or "bob" in the author field:

ms.search({
  queries: [
    { fields: ['title'], queries: ['people'] },
    { fields: ['author'], queries: ['bob'] }
  ]
})
// => [{ id: 4, ... }, { id: 3, ... }]

Both documents 4 and 3 are returned, but 4 scores higher because it matches both subqueries, while 3 only matches the one for the author field.

Instead, this finds all documents that contain "people" in the title field and "bob" in the author field:

ms.search({
  queries: [
    { fields: ['title'], queries: ['people'] },
    { fields: ['author'], queries: ['bob'] }
  ],
  combineWith: 'AND'
})
// => [{ id: 4, ... }]

In this case, only document 4 is returned, because it is the only one that has both "people" in the title field and "bob" in the author field. The score for document 4 is the same as above, but 3 is discarded completely.

If we imagine a query language where we can put the query string in quotes, followed by the field after a semicolon, and use AND and OR to combine queries, the first example would be "people":title OR "bob":author, the second example would be "people":title AND "bob":author.

If that's not resolving your issue, and you can share a link to the document JSON and the query, I can definitely have a look.

mastercoms commented 1 year ago

Thanks so much for the thorough explanation! I looked everything over, and I'm pretty sure my search syntax and combineWith are correct, but I might be wrong. I've provided the query string, and query objects below to verify along with the results. The search website is available here along with relevant source code here, just in case you also needed that.

Document JSON

https://comfig.app/huds/search.json

Working case

Without field syntax

query string: 7hud

parsed query object:

"7hud"

search options:

{
  "boost": {
    "name": 5,
    "author": 2
  },
  "prefix": true
}
Results ```json [ { "id": "7hud", "score": 41.50819178403512, "terms": [ "7hud" ], "match": { "7hud": [ "name" ] }, "name": "7HUD", "author": "sevin", "content": "description\n\noriginally based off an old ya version. hope you guys like it. updates are typically delayed because i'm a full-time student, but i love tf2 and can't live without this hud anymore, so you can always expect an update at some point. you should grab 4plug to take full advantage of the customization of this hud.\n\nscreenshots | github | group | google doc | 4plug\n\ncredits\n\nwhayay - original ya_hud base\n\nspecial thanks\n\ndoodle - excellent guide and resource list\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/7hud/7hud-banner.webp" }, { "id": "peachhud", "score": 3.2223024281563335, "terms": [ "7hud" ], "match": { "7hud": [ "content" ] }, "name": "PeachHUD", "author": "Peaches", "content": "description\n\na team fortress 2 hud made by peaches and streamlined for competitive, while maintaining a clean and minimalistic look.\nbased on sunsethud, by hypnotize.\n\nscreenshots (not sure why this is marked 18+)\ngithub\n\nfrequently asked questions:\n\nwhere's the friends-list?\nit is a known source of fps drops. re-enable it in customizations/friendslist.res.\nwhy can't i join my friend's party?\nthat's a steam api bug unrelated to custom huds.\nwhere's the little person in the bottom left?\nit is a known source of fps drops. re-enable it in customizations/classmodel.res.\ndoes this work on linux/mac?\nrename the downloaded folder to be lowercase, then probably.\n\nplease do not commission others to edit my hud. others are welcome to edit the hud voluntarily, but others should not profit off my hud.\n\ncredits\n\neverything: hypnotize\ninspiration: budhud, rayshud, 7hud, m0rehud, hypnotizehud, and toonhud\nmaterial design vtfs: extracrispy and rawsor\ncrosshairs: broesel, knuckles, seeker, and m0re\n\nspecial thanks\n\nto hypnotize for mentoring me throughout my devlopment of this hud.\n", "flags": [ "fonts", "menus", "scoreboards", "crosshairs", "minmode", "streamer-mode", "materials", "customization" ], "tags": [ "minimal" ], "os": [ "windows", "mac", "linux" ], "gamemode": [ "tournament", "comp", "arena", "ad", "ctf", "cp", "halloween", "koth", "mannpower", "mvm", "pass", "pl", "plr", "pd", "rd", "sd", "tc" ], "res": [ "4/3", "5/4", "16/10", "16/9", "17/9", "21/9" ], "position": [ "center", "corners" ], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/peachhud/PeachHUD-banner.webp" } ] ```

So without any field queries, we have both 7hud and PeachHUD returned.

With field syntax

query string: name:7hud

parsed query object:

{
  "combineWith": "AND",
  "queries": [
    {
      "fields": [
        "name"
      ],
      "queries": [
        "7hud"
      ],
      "combineWith": "OR"
    }
  ]
}

search options:

{
  "boost": {
    "name": 5,
    "author": 2
  },
  "prefix": true
}
Results ```json [ { "id": "7hud", "score": 41.50819178403512, "terms": [ "7hud" ], "match": { "7hud": [ "name" ] }, "name": "7HUD", "author": "sevin", "content": "description\n\noriginally based off an old ya version. hope you guys like it. updates are typically delayed because i'm a full-time student, but i love tf2 and can't live without this hud anymore, so you can always expect an update at some point. you should grab 4plug to take full advantage of the customization of this hud.\n\nscreenshots | github | group | google doc | 4plug\n\ncredits\n\nwhayay - original ya_hud base\n\nspecial thanks\n\ndoodle - excellent guide and resource list\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/7hud/7hud-banner.webp" } ] ```

So with the field query, we have just 7hud returned, as expected. So seems to be working. However...

Non-working cases

With just name field

query string: name:Hypnotize

parsed query object:

{
  "combineWith": "AND",
  "queries": [
    {
      "fields": [
        "name"
      ],
      "queries": [
        "hypnotize"
      ],
      "combineWith": "OR"
    }
  ]
}

search options:

{
  "boost": {
    "name": 5,
    "author": 2
  },
  "prefix": true
}
Results ```json [ { "id": "m0re-hypnotize", "score": 43.51915242842479, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "name", "author" ] }, "name": "m0re Hypnotize", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0re-hypnotize/m0re-hypnotize-banner.webp" }, { "id": "hypnotizehud", "score": 22.411164512666453, "terms": [ "hypnotize", "hypnotizehud" ], "match": { "hypnotize": [ "author" ], "hypnotizehud": [ "name" ] }, "name": "HypnotizeHUD", "author": "Hypnotize", "content": "\n\n material tf2 hud which aims to keep a clean and minimalistic design\n\n screenshots\n github\n gamebanana\n hud editor\n hud wiki\n customization\n\n\ncredits\ninspiration:** m0re, colly, pigby, jarateking, omnibombulator, extracrispy, whisker, wiethoofd\nhud help & feedback:** bla, zetos, qkeitoe, jarateking, whisker, wiethoofd, my italian buddies and the whole huds.tf discord\ncrosshairs:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nstreamer mode:** whisker, omnibombulator\nmaterial design vtfs:** extracrispy & rawsor\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/hypnotizehud/hypnotizehud-banner.webp" }, { "id": "1-shot", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "1 Shot", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/1-shot/1-shot-banner.webp" }, { "id": "ahud-m0rehud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "ahud-m0rehud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/ahud-m0rehud/ahud-m0rehud-banner.webp" }, { "id": "hexhud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "HExHUD", "author": "Hypnotize", "content": "\n\n custom tf2 hud focused on hexagon shapes\n\n screenshots\n github\n gamebanana\n tf.tv\n hud editor\n hud wiki\n customization\n\n\ncredits\ngeneral inspiration:** colly, pigby, omnibombulator, m0re\ncrosshairs & hitmarkers:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nbutton animation inspiration:** devamar, jarateking\ndamage color switcher:** pigby\nstreamer mode:** whisker, omnibombulator\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\nlogo design:** zetos\nsfms:** red vs blue clash by tonyc445, scientific studies by hidden-maverick\nhud editor support:** criticalflaw, revan\nhud help, feedback and ideas:** zetos, jackylegs, jarateking, omnibombulator, and the whole huds.tf discord\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/hexhud/hexhud-banner.webp" }, { "id": "kx-hud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "KX-Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/kx-hud/kx-hud-banner.webp" }, { "id": "lighthud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "LightHUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/lighthud/lighthud-banner.webp" }, { "id": "m0rehud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "m0rehud", "author": "Hypnotize", "content": "\n\n clean, functional and minimalistic tf2 hud created by m0re.\n\n screenshots\n github\n gamebanana\n tf.tv\n hud wiki\n customization\n\n\ncredits\nm0re:** creator of m0rehud\nwiethoofd:** uber counter\nbroesel, knuckles, seeker, m0re, fog, toonhud, garm3n:** hud crosshairs\nwaldo, quickkennedy, sgtpugs, peaches:** speedometer\nzimmy, gunblade, ninjadc, zenfor:** for maintaining m0rehud before i started to\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-banner.webp" }, { "id": "metro-hud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Metro Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/metro-hud/metro-hud-banner.webp" }, { "id": "noto-kn", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Noto-KN", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/noto-kn/noto-kn-banner.webp" }, { "id": "shrekhud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "ShrekHUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/shrekhud/shrekhud-banner.webp" }, { "id": "soft-hud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Soft Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/soft-hud/soft-hud-banner.webp" }, { "id": "sunsethud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "SunsetHUD", "author": "Hypnotize", "content": "\n\n a very bright tf2 hud based on material design\n\n screenshots\n github\n gamebanana\n tf.tv\n hud editor\n hud wiki\n customization\n\n\ncredits\ninspiration:** colly, pigby, jarateking, omnibombulator, extracrispy, whisker\nhud help & feedback:** jackylegs, jarateking, peaches, whisker, bla, my italian buddies and the whole huds.tf discord\ncrosshairs:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nstreamer mode:** whisker, omnibombulator\nmaterial design vtfs:** extracrispy & rawsor\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/sunsethud/sunsethud-banner.webp" }, { "id": "tf2-recording-hud", "score": 7.931562727537921, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "TF2 Recording HUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/tf2-recording-hud/tf2-recording-hud-banner.webp" } ] ```

For some reason, it also returns results where the author field matches the query. And even if I also specify author as well just in case, it still does this:

With both name and author fields

query string: name:Hypnotize author:Hypnotize

parsed query object:

{
  "combineWith": "AND",
  "queries": [
    {
      "fields": [
        "name"
      ],
      "queries": [
        "hypnotize"
      ],
      "combineWith": "OR"
    },
    {
      "fields": [
        "author"
      ],
      "queries": [
        "hypnotize"
      ],
      "combineWith": "OR"
    }
  ]
}

search options:

{
  "boost": {
    "name": 5,
    "author": 2
  },
  "prefix": true
}
Results ```json [ { "id": "m0re-hypnotize", "score": 87.03830485684958, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "name", "author" ] }, "name": "m0re Hypnotize", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0re-hypnotize/m0re-hypnotize-banner.webp" }, { "id": "hypnotizehud", "score": 44.822329025332905, "terms": [ "hypnotize", "hypnotizehud" ], "match": { "hypnotize": [ "author" ], "hypnotizehud": [ "name" ] }, "name": "HypnotizeHUD", "author": "Hypnotize", "content": "\n\n material tf2 hud which aims to keep a clean and minimalistic design\n\n screenshots\n github\n gamebanana\n hud editor\n hud wiki\n customization\n\n\ncredits\ninspiration:** m0re, colly, pigby, jarateking, omnibombulator, extracrispy, whisker, wiethoofd\nhud help & feedback:** bla, zetos, qkeitoe, jarateking, whisker, wiethoofd, my italian buddies and the whole huds.tf discord\ncrosshairs:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nstreamer mode:** whisker, omnibombulator\nmaterial design vtfs:** extracrispy & rawsor\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/hypnotizehud/hypnotizehud-banner.webp" }, { "id": "1-shot", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "1 Shot", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/1-shot/1-shot-banner.webp" }, { "id": "ahud-m0rehud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "ahud-m0rehud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/ahud-m0rehud/ahud-m0rehud-banner.webp" }, { "id": "hexhud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "HExHUD", "author": "Hypnotize", "content": "\n\n custom tf2 hud focused on hexagon shapes\n\n screenshots\n github\n gamebanana\n tf.tv\n hud editor\n hud wiki\n customization\n\n\ncredits\ngeneral inspiration:** colly, pigby, omnibombulator, m0re\ncrosshairs & hitmarkers:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nbutton animation inspiration:** devamar, jarateking\ndamage color switcher:** pigby\nstreamer mode:** whisker, omnibombulator\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\nlogo design:** zetos\nsfms:** red vs blue clash by tonyc445, scientific studies by hidden-maverick\nhud editor support:** criticalflaw, revan\nhud help, feedback and ideas:** zetos, jackylegs, jarateking, omnibombulator, and the whole huds.tf discord\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/hexhud/hexhud-banner.webp" }, { "id": "kx-hud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "KX-Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/kx-hud/kx-hud-banner.webp" }, { "id": "lighthud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "LightHUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/lighthud/lighthud-banner.webp" }, { "id": "m0rehud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "m0rehud", "author": "Hypnotize", "content": "\n\n clean, functional and minimalistic tf2 hud created by m0re.\n\n screenshots\n github\n gamebanana\n tf.tv\n hud wiki\n customization\n\n\ncredits\nm0re:** creator of m0rehud\nwiethoofd:** uber counter\nbroesel, knuckles, seeker, m0re, fog, toonhud, garm3n:** hud crosshairs\nwaldo, quickkennedy, sgtpugs, peaches:** speedometer\nzimmy, gunblade, ninjadc, zenfor:** for maintaining m0rehud before i started to\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/m0rehud/m0rehud-banner.webp" }, { "id": "metro-hud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Metro Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/metro-hud/metro-hud-banner.webp" }, { "id": "noto-kn", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Noto-KN", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/noto-kn/noto-kn-banner.webp" }, { "id": "shrekhud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "ShrekHUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/shrekhud/shrekhud-banner.webp" }, { "id": "soft-hud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "Soft Hud", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/soft-hud/soft-hud-banner.webp" }, { "id": "sunsethud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "SunsetHUD", "author": "Hypnotize", "content": "\n\n a very bright tf2 hud based on material design\n\n screenshots\n github\n gamebanana\n tf.tv\n hud editor\n hud wiki\n customization\n\n\ncredits\ninspiration:** colly, pigby, jarateking, omnibombulator, extracrispy, whisker\nhud help & feedback:** jackylegs, jarateking, peaches, whisker, bla, my italian buddies and the whole huds.tf discord\ncrosshairs:** broesel, knuckles, seeker, m0re, fog, toonhud, garm3n\nclosed captions:** clovervidia\nstreamer mode:** whisker, omnibombulator\nmaterial design vtfs:** extracrispy & rawsor\ntransparent viewmodels:** jarateking, komorebi\nspeedometer:** waldo, quickkennedy, sgtpugs, peaches\n", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/sunsethud/sunsethud-banner.webp" }, { "id": "tf2-recording-hud", "score": 15.863125455075842, "terms": [ "hypnotize" ], "match": { "hypnotize": [ "author" ] }, "name": "TF2 Recording HUD", "author": "Hypnotize", "content": "", "flags": [], "tags": [], "os": [], "gamemode": [], "res": [], "position": [], "bannerUrl": "https://raw.githubusercontent.com/mastercomfig/hud-db/main/hud-resources/tf2-recording-hud/tf2-recording-hud-banner.webp" } ] ```
lucaong commented 1 year ago

Thanks a lot for the detailed example. I think I know what’s going on, and it’s definitely something that can be fixed in MiniSearch.

The problem is that the current logic ends up including in the search all fields that are either in the fields option or in the boost option. That’s a bug, which I will fix as soon as I can work on it: the boost option should have no effect on the considered fields. Even though boosting fields that are not considered for search is useless, it should not interfere with the results.

In the meanwhile, if it’s acceptable to temporarily remove the boosts from the search options, you should see the issue disappearing. Alternatively, you could remove the boosting from the search options and add it to each query, but only for the considered fields.

Thanks again for reporting this, I will comment here once the issue is resolved.

mastercoms commented 1 year ago

Yep that workaround works! Thanks so much by the way, you have been exceedingly helpful!

lucaong commented 1 year ago

Happy to help :) I just merged #200 , which fixes the issue you isolated (and another small related one I found in the same code path), and released version v6.0.1 on NPM. You should now be able to upgrade, and use the boost option like you did in your examples above, without incurring in the issue.

Thanks again for the detailed issue report!

mastercoms commented 1 year ago

Wow, thank you so much!