This is the first time I'm working with RavenDB. I am not in a position to ask the creators of the code why they made certain decisions, so I am turning to internet strangers and hoping for some kindness.
There are a number of search queries throughout the code and they all look like:
query.AndAlso().Search("Content", $"*searchExpression*");
The query
is a RavenDB IDocumentQuery
. The property Content
is not defined on the document that is being searched for.
I think that this performs a search on all the properties in the document. Unfortunately I cannot find any documentation on this, so I am not sure how this impacts performance, security and injection attacks. I'm not even sure if this is actively discouraged.
Can somebody shine some light on this? Even if it's just the direction of my google searches as "ravendb search on content" does not return a lot of useful articles.
Edit: To clarify, I understand the syntax of the Search
method. It takes the property to search and then an expression that is being searched for. But I have a document
public class Person {
public string FirstName {get; set;}
public string LastName {get; set;}
public DateTime DateOfBirth {get; set;}
}
The Search
remains the same as above. There is no "Content" property in this Person
document. Yet it does search on something, because I can see the list of documents get filtered. I just don't know what it's filtering on.
The first parameter to the
.Search
method is the property selector.An expression marking the document field in which the terms should be looked for.
See method definition:
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/src/Raven.Client/Documents/Session/IDocumentQueryBase.cs#L187
You can see a usage example in these tests:
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/test/SlowTests/Issues/RavenDB_5669.cs#L17
https://github.com/ravendb/ravendb/blob/904c34a939c35c6375726a57e6eb475086355fa7/test/SlowTests/Issues/RavenDB_5669.cs#L45