Getting no results with match_all Query


#1

I have this structure:

{
   "_id": "001",
   "information": "Free Books",
   "date": "2015-07-06",
   "books": [
       {
           "title": "New Era",
           "author": "David Smith"
       },
       {
           "title": "The Warrior",
           "author": "John Calton"
       },
       {
           "title": "A great leader",
           "author": "Ana Marques"
       },
       {
           "title": "Be like water",
           "author": "Bruce Lee"
       }
   ]
}

When I try to do a simple query like match all, I get no results:

{
    "query":{
        "match_all": {}
    }
}

Then, when I create a new document without using array, I'm able to get the proper results in any query. I guess the problem is that I'm not using nested objetcs for the array, however, shoud not the "match_all" query return me the results?

The index I've created:

curl -XPUT "localhost:9200/_river/mylibrary/_meta" -d "{
    "type" : "couchdb",
    "couchdb" : {
        "host" : "localhost",
        "port" : 5984,
        "db" : "mylibrary",
        "filter" : null
    },
    "index" : {
        "index" : "mylibrary",
        "type" : "mylibrary",
        "bulk_size" : "100",
        "bulk_timeout" : "10ms"
    }
}"

Why am I not getting the results?


(David Pilato) #2

Don't use rivers. They will be removed in 2.0.


#3

Is there another way to use data from couchdb without using rivers in this case? However, what is the problem with the match_all query that is not returning any result?


(David Pilato) #4

Logstash couchdb input might help.

If match all does not give any hits, it's most likely because you (or the river) did not index any doc.


#5

I think the problem is not about indexing because I removed the array from the document, then the query worked as expected. If I put some array in the document, query stop giving me results. Even the match_all. If I leave just strings, without array in Json, everything works fine...


(David Pilato) #6

Your document looks good.

May be you can reproduce with a script the problem without using a river?
PUT directly your docs in elasticsearch


#7

Thank you. Do you have any reference showing how to synchronize data from CouchDB? I took a look at Logstash, but I got confused where should I put informations like: host, port number and index.

In river I used to put everything in localhost/_river/_meta like this:

curl -XPUT 'localhost:9200/_river/my_db/_meta' -d '{
    "type" : "couchdb",
    "couchdb" : {
        "host" : "localhost",
        "port" : 5984,
        "db" : "my_db",
        "filter" : null
    },
    "index" : {
        "index" : "my_db",
        "type" : "my_db",
        "bulk_size" : "100",
        "bulk_timeout" : "10ms"
    }
}

(David Pilato) #8

Everything is documented here: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-couchdb_changes.html

If you don't succeed of making it work, open a new thread in the logstash section.


(system) #9