V
V
Vlad Timofeev2015-01-22 15:22:22
JavaScript
Vlad Timofeev, 2015-01-22 15:22:22

How to search given data in elasticsearch with from & size fields?

Good day.
There is a module https://github.com/mongoosastic/mongoosastic
In elasticsearch.js This is done like this:

client.search({
  index: 'posts',
  from: (pageNum - 1) * perPage,
  size: perPage,

When I tried to do this in mongoosastic like this:
Post.search({
    query_string: {
      query: 'client',
    },
    from: 3,
    size: 3
  }

It gives me an error and results = undefined
a481c462113249a19d06b317e94a9a56.png
How to do this trick?
Or take elasticsearch.js and use it for all searches using the client.search method, and leave indexing with the save method to mongoosastic ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MintTea, 2015-01-22
@PyTiMa

If I understand your nodejs correctly, then judging by the source of the schema.statics.search function, the request should look something like this:

Post.search(
    {query_string: {query: 'client'}},
    {from: 3, size: 3},
    function() { /* callback */ }
);

V
Vlad Timofeev, 2015-01-22
@PyTiMa

Why is everything so sad? :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question