alexandernst
alexandernst

Reputation: 15099

ElasticSearch and MongoDB

I'm willing to run full-text queries in MongoDB, using ElasticSearch. I found some guides about how to setup ElasticSearch using this, but I have a few questions.

1: I'm supposed to run this

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{ 
    "type": "mongodb", 
    "mongodb": { 
        "db": "testmongo", 
        "collection": "person"
    }, 
    "index": {
        "name": "mongoindex", 
        "type": "person" 
    }
}'

to make ElasticSearch index that collection. Do I need to run this more than once? (Every time my collection is updated? Once per day?)

2: Is there full support for paging and ordering? I'd like to search for something, but limiting the result to N results per page, and skip some pages. Also, I'd like to order by any field.

3: My data looks like this:

{
    question: 'text here', 
    date: '01/01/2000 01:01',
    title: 'Some title',
    client: 'name',
    assigned_to: ['name1', 'name2', 'name3'],
    answers: [
        {answer: 'bla bla'}, 
        {answer: 'bla bla'}, 
        {answer: 'bla bla'}
    ]
}

Will I be able to search in question, title and all the answers?

Upvotes: 3

Views: 1122

Answers (1)

Kali
Kali

Reputation: 36

  1. no you need not run that every time a collection gets updated. a index is refreshed according to the refresh interval in config or manually by invoking "_refresh"

  2. yes there is support for paging,sorting using fields "from", "size", "sort" in the query please see

    ElasticSearch Pagination & Sorting

  3. yes you can search in anyfield please see http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/

Upvotes: 2

Related Questions