Hello all,
I'm a brand new developer using elastic search, and I'm struggling to accomplish what seems to be a simple task: filtering documents that I don't want from my search result result.
My index consists, among others, a content field and a projectId field. So, I want to simply search for a document which its content posses the keyword "construction" and the projectId must be equal a GUID.
The thing is, it does not matter how hard I try, I get my desired document at the first position, but then I got others documents that may have "construction" in the content field, but the projectId is not the same I want to filter.
The last version of my code looks like:
var response = await _elastic.SearchAsync<ProjectDocumentESModel>(s => s.RequestConfiguration(c => c.DisableDirectStreaming())
.Index("*")
.Query(q =>
q.Terms(p => p.Field(f => f.Content).Terms(keyword))
&&
q.Bool(b => b
.Filter(f => f.Match(m => m.Field(f => f.ProjectId).Query(projectId.ToString())))
)
)
);
What am I missing here? Please help me.