Text and Numeric value Search

Hi guys;

I am currently working on an app with a database already created by my client, so far everything is fine, my indexes work fine, pagination, sort, filters, everything except the search capabilities, I have already seen all the examples in the forums, but none works with what I need to implement.

For example, I have the following documents in a specific collection:

{
  after: [Ref(Collection("Ejemplares"), "296419291078593037")],
  data: [
    {
      ref: Ref(Collection("Ejemplares"), "296419291078590989"),
      ts: 1618946314926000,
      data: {
        ejemplar: 901804207,
        especie: "BOVINO",
        raza: "ENCASTADO JERSEY",
        fecharegi: "2021-04-14",
        prefijo: "SYMM",
      }
    },
    {
      ref: Ref(Collection("Ejemplares"), "296419291078592013"),
      ts: 1618946314926000,
      data: {
        ejemplar: "901804209",
        especie: "BOVINO",
        raza: "HOLSTEIN/PARDO",
        fecharegi: "2021-04-14",
        prefijo: "SYMM",
      }
    }
  ]
}

Sometimes the value of Ejemplar will be text type and other times will be numeric type.

In this case, is there any method to find its value regardless of what type of data it is?

Any contribution will be very helpful!!

You could create an index with a binding that calls ToString on the ejemplar field, and then include the binding’s name in the index’s terms field. That would provide a “virtual” field to the index that would always be a string.

For more details, see: Indexes | Fauna Documentation

Thanks @ewan …really love fauna, now I am trying to implement full text search capabilities over the index with the binding value…

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.