orama icon indicating copy to clipboard operation
orama copied to clipboard

Can't search numbers or booleans

Open mateonunez opened this issue 2 years ago • 1 comments

Describe the bug As defined in the type, is not possible to search terms different than strings.

image

To Reproduce Steps to reproduce the behavior:

import {create, insert, search} from "@lyrasearch/lyra"

(() => {
  const lyra = create({
    schema: {
      author: "string",
      website: "string",
      contributors: "number",
      stars: "number",
      forks: "number",
      language: "string"
    }
  })

  insert(lyra, {
    author: "Lyra",
    website: "https://github.com/LyraSearch",
    contributors: 21,
    stars: 3350,
    forks: 62,
    language: "TypeScript"
  })

  const {hits} = search(lyra, { term: 62 })
})()

Expected behavior Lyra's searches should support the types of the PropertiesSchema declared.

Anyway, whether I try to cast "62" (forks property) into a string, the hits are empty.

import {create, insert, search} from "@lyrasearch/lyra"

(() => {
  ...

  const {hits} = search(lyra, { term: "62" })
  console.log({hits}) // empty
})()

Desktop (please complete the following information):

  • Lyra v0.2.4
  • Node v18.9.0

UPDATED: Additional context Playing with node_modules and the build of Lyra, changing the type of term is working fine:

Boolean image

Number image

mateonunez avatar Sep 28 '22 11:09 mateonunez

Hi @mateonunez @micheleriva My previous #36 aimed to resolve this issue as a side effect. In particular, I used a sorted list for numbers (to use range queries), every item contains the number and the index. For the booleans, I used a hashmap of sets, the key was name_of_the_field{{boolean_value}} and the value was a set of ids.

Please tell me if this solution is feasible so I can take this part from the PR since that feature seems dead.

DanieleFedeli avatar Oct 26 '22 09:10 DanieleFedeli

Released in v0.4.9

micheleriva avatar Feb 15 '23 13:02 micheleriva