mercredi 18 mars 2020

random list with searchkick error Can't get text on a START_ARRAY

I'm trying to list 15 randoms items with searchkik in rails. I've found some examples and I code this

      body: {
    size: 15,
      query:
        {
          function_score:
            {
              query: {
                  match: { ceased_on: nil },
                  match: { is_public: true },
                  match: { _or: @region.departments.map { |department| { zipcode: { prefix: department.number } } } },
                },
                random_score: {seed: DateTime.now.to_i}
              }
            }
        }

when I launch the server. I've an error who say:

[500] {"error":{"root_cause":[{"type":"illegal_state_exception","reason":"Can't get text on a START_ARRAY at 1:63"}],"type":"illegal_state_exception","reason":"Can't get text on a START_ARRAY at 1:63"},"status":500}

I've search on google why I've this error and I understand that is because of searchkick doesn't like array but I've no idea how to fix it. Thanks and have a good evening




Aucun commentaire:

Enregistrer un commentaire