I have a “Client” table that has a string field called Name. I have created an index that seems to work vary quickly when I execute the N1QL statement 'select * from Ngage data where type=‘Client’ and name = ‘Some Client Name’.
The index creation looks like this:
CREATE INDEX ngage_client_name ON Ngage(name) WHERE (type = “Client”)
When it comes to me using a Linq call like this:
var query = from client in CacheProvider.BucketContext.Query()
where client.Name == n
The call takes forever. I have to assume that the parameter names described in the index create are not the same in the N1QL created. Can anyone please help me figure out how I should create the index to work with Linq?
With indexes in N1QL, I believe the predicate needs to match exactly to select the index. Since you indicate type client and name, your index will probably require both of those.
As you point out though, after this goes through LINQ, the statement may be different. There are a few options for observing what’s being done underneath. You can check with the REST API against the query service for completed requests. Or, you can just maybe write a small program and crank up the log level to see the statements being issued.
One other thing to point out, since it looks like you’re using Linq2Couchbase (although I would expect to see Query<Client>(…) instead of Query(…), but maybe the forum software ate your angle brackets)
@vsr1 said that you must add “type = ‘Client’” to your query.