I use Mango queries with Couchdb when users want to search the database. They can search by multiple fields in the document.
To simplify I have a document with three fields all of which can be searched to find the document.
FieldOne: cow
FieldTwo: pig
FieldThree: dog
When creating a mango index for the query what fields should I use? Should I create and index with multiple fields? Does the order matter?
There are also three different document types (A, B C) defined in a field. I only need to search one, is it possible to exclude the other types from the index to make it faster?
Field_Type: A
It would make sense to me to be able to run an index against a view to only search through the documents I am interested in. Is this possible?
Example indexes
One index on field known to appear in the query
{
"index": {
"fields": [
"FieldOne"
]
},
"name": "foo-json-index",
"type": "json"
}
Multiple indexes, not sure if used or not?
{
"index": {
"fields": [
"FieldOne",
"FieldTwo",
"FieldThree"
]
},
"name": "foo-json-index",
"type": "json"
}
Or multiple indexes to choose the correct one when building the query?
which is the correct approach to get the fastest search results?