RavenDB Remote Property Request Documents

In RavenDB Studio, I can view 69 CustomVariableGroup documents. My query returns only 66 of them. After some digging, I see that three documents that have not been returned have a new class structure: the property has been deleted. Since I saved these three CustomVariableGroup documents, their structure is different from the other 66. Why, though, when I request all of them, I can only get the remaining 66 documents with the old structure?

Both my C # code and my request in LinqPad, return 66. Here's the LinqPad request:

Session.Query<CustomVariableGroup>().Dump(); // returns 66 docs 

But if I do this, I can get one of three documents that are not in the above request:

 Session.Query<CustomVariableGroup>().Where(x => x.Name == "Derating").Dump(); 

How can I get all 69 documents returned in one request?

** Edit: Index Information **

On the SQL tab of the LinqPad query (and on the output of the Raven server), the index looks like this:

Url: / indexes / dynamic / CustomVariableGroups? query = & start = 0 & pageSize = 128 & aggregation = None

I do not see this index in Raven Studio, presumably because it is dynamic.

** Edit 2: This HACK works **

If I do this, I will receive all 69 documents:

 Session.Query<CustomVariableGroup>().Where(x => x.Name != string.Empty).Dump(); 

I assume Raven should use an old index that only gets documents that still contain this remote column. I somehow need to use a new / different index ...

Interestingly, this does not work; it returns only 66:

 Session.Query<CustomVariableGroup>().Where(x => x.Id != string.Empty).Dump(); 

** Edit 3: This HACK also works **

 Session.Advanced.LuceneQuery<CustomVariableGroup>("Raven/DocumentsByEntityName").Where("Tag:CustomVariableGroups").Dump(); 
+2
source share
3 answers

An index with an old property must be deleted.

** Until ** This did not work (only 66 of 69 documents were returned):

 Session.Query<CustomVariableGroup>().Dump(); 

** Fix ** Delete the index that used the old property that was removed from my C # class:

In Raven Studio, I deleted this index: Auto / CustomVariableGroups / ByApplicationId

** After ** This same query now returns all 69 documents:

 Session.Query<CustomVariableGroup>().Dump(); 

Now I'm not sure why these queries will use this index. I request CustomVariableGroup for all documents, not ByApplicationId. However, the removal of this index is fixed. I'm sure someone else can explain why.

+2
source

What do indexes look like? Did you manually create indexes or dynamically create? Just wondering if this is the cause of the problem based on your comments above that there was a change in the structure of the object.

- S

0
source

Maybe this is an outdated index .. if it does not return all the results you expect.

you can use

.Customize (x => x.WaitForNonStaleResultsAsOfLastWrite ())

0
source

Source: https://habr.com/ru/post/911374/


All Articles