View not returning specified documents


#1

I’m having some trouble I was hoping you could help me with.

I’m doing all of this through the admin console.

When I lookup a particular document through the console, I can find it.
But when I write a view to find that particular document, I can’t find it.

Similarly, there are several documents that contain particular information ( { “type” : “context” } ) that I made, so I know they exist in the db. Yet when I create a view to find documents with that information, the documents that I made do not come up.

Is the view not indexed/indexing? Or is there some other problem?

EDIT: Nevermind! The problem was that I was using the development view, which doesn’t automatically check the entire db.


#2

If your view is indexing you should see it in the admin console. A little green bar should appear at the top right saying its indexing your view, similar to this one but it would saying indexing:

Also on the Views page for that bucket (Go to Views, then select the bucket with your documents in it from the dropdown at the top) it should say Indexing and the percentage next to the view name, under the Status column. In my experience after I change a view I have to run a search on it in the console (which will return nothing) to get it to start the indexing.

A sample view to get what you want would probably look like this (assuming you want to search on a parameter called ‘name’ in your document, change doc.name in the emit function to what you want to search on):

function (doc, meta) {
  if (doc.type == 'context') {
      emit(doc.name, null);
  }
}

#3

Glad this worked. This is a “safety” feature for developing views, as it minimizes the overhead for the view engine when trying out new map reduce views.