Multiple queries not working as expected
pardahlman opened this issue ยท 2 comments
Hello @ju2pom - awesome job with this library ๐.
I've been playing around with the Everything SDK myself, but havn't been able to get multiple "active" queries for Everything to work (that is somehow use replyId
and get results for that query). This got me searching for other solution which is how I found your repo.
I cloned it and in order to run the MultipleInstances
acceptance test, which looks like what I was trying to do. However, when stepping through your code, I realized that it worked because the query is executed as the result is enumerated (by the ExecuteIfNeeded
call). This test fails if you copy the first assert and run it again after the second assert
Assert.That(firstResult.First().FileName, Is.EqualTo("IImageQueryable.cs"));
Assert.That(secondResult.First().FileName, Is.EqualTo("IMusicQueryable.cs"));
Assert.That(firstResult.First().FileName, Is.EqualTo("IImageQueryable.cs")); // <-- add this
The test fails with the following exception
String lengths are both 18. Strings differ at index 1.
Expected: "IImageQueryable.cs"
But was: "IMusicQueryable.cs"
------------^
at AcceptanceTests.cs:line 191
From what I can gather from the documentation the Everything_SetReplyID
call is only relevant when using a reply window and not waiting waiting for the query
Set a unique identifier for the IPC Query. If you want to post multiple search queries with the same window handle, you must call the Everything_SetReplyID function to assign each query a unique identifier. The nID value is the dwData member in the COPYDATASTRUCT used in the WM_COPYDATA reply message. This function is not required if you call Everything_Query with bWait set to true.
Keep up the good work!
Hi,
Thanks for your positive feedback, it's always nice to hear !
About the issue you are reporting, your are completely right.
When implementing the unit test I've been lead into error because of the "lazy" evaluation of the returned enumerable.
After reading again the documentation I don't see how I can
- use
Everything_Query(true)
- lazy evaluate the results
I should think of some way in the API to allow true multithread search working as expected!
That's my conclusion as well. And if wait
is set to false
the responses will be published to the reply window, which I don't believe is available - but perhaps I'm wrong ๐คทโโ๏ธ. In my implementation, I'll evaluate the entire search result before allowing second query to be executed.
Good luck!