flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

Searching for numbers

Open alisomay opened this issue 7 years ago • 6 comments

When I search for a field which contains a number, the result is an empty array, I feel that there must be a very clear point that I am missing, could you explain the behaviour? Thank you very much.

const test = [
  {
    data: {
      id: 0,
      name: "foo",
      val: 1
    }
  },
  {
    data: {
      id: 1,
      name: "bar",
      val: 2
    }
  }
]

 const index = new FlexSearch({
    async: true,
    doc: {
      id: "data:id",
      field: ["data:name", "data:val"]
    }
  });

  index.add(test);

  index
    .search(1, {
      field: "data:val"
    })
    .then(result => {
      console.log(result);
//returns empty array
    });
  index
    .search("bar", {
      field: "data:name"
    })
    .then(result => {
      console.log(result);
//returns the object it found
    });

alisomay avatar Oct 03 '19 14:10 alisomay

having similar issue . trying to store ip addresses + masks, for example 10.10.10.10/24 full range for some reason cant get match properly if giving exact ip from that range .

ViljarVoidula avatar Dec 10 '19 17:12 ViljarVoidula

Same here

machado-r avatar Dec 17 '19 21:12 machado-r

I'm still facing this issue, unable to search for numbers ! Did anyone find a solution to this yet? @machado-r @ViljarVoidula @alisomay ? Any updates regarding this @ts-thomas?

maazkabir avatar Jan 19 '20 14:01 maazkabir

@maazkabir Sorry for replying 6 months later. I did not find a solution so I switched to Fuse.Js.

machado-r avatar Jul 03 '20 19:07 machado-r

I also have the problem. I'm using another field that I built from the number: a string with a symbol to make it searchable.

It's not perfect but it's a temporary workaround.

@ts-thomas Maybe version 0.7.0 will solve the problem?

benjaminbarbe avatar May 18 '21 14:05 benjaminbarbe

Please use a custom "encode" function which allows special chars like "." or "/"

ts-thomas avatar Jun 28 '21 11:06 ts-thomas