Is there a way to include a wildcard in an Examine NativeQuery call?
I've noticed that Examine strips out the wildcard indicator when using the NativeQuery method. For example, if I pass "someProperty:test*^5" to it, it gets converted to "someProperty:test^5." While adding the wildcard via the Examine MultipleCharacterWildcard string extension does work, I'm not aware of any way of combining that with boosting.
Is there a setting I'm missing, or is this a limitation of Examine?
I honestly can't tell you if there is a way to use it in the NativeQuery, but if you have another way to do the query you want I would go with that and do the boosting when creating the index.
Like this:
public class CustomizeIndexComposer : ComponentComposer<CustomizeIndexComponent>
{
}
public class CustomizeIndexComponent : IComponent
{
private readonly IExamineManager _examineManager;
public CustomizeIndexComponent(IExamineManager examineManager)
{
_examineManager = examineManager;
}
public void Initialize()
{
// get the external index
if (!_examineManager.TryGetIndex(Constants.UmbracoIndexes.ExternalIndexName, out IIndex index))
return;
if (!(index is LuceneIndex luceneIndex))
{
throw new InvalidOperationException("Could not cast");
}
luceneIndex.DocumentWriting += LuceneIndex_DocumentWriting;
}
private void LuceneIndex_DocumentWriting(object sender, DocumentWritingEventArgs e)
{
if (e.ValueSet.Category == "content")
{
var field = e.Document.GetField("heroHeader");
if(field != null)
field.Boost = 29f;
var field2 = e.Document.GetField("nodeName");
if(field != null)
field2.Boost = 30f;
}
}
public void Terminate()
{
}
}
I wasn't aware that we could do that. Good to know. While that does work around the issue, it's not quite what I'm looking for, as my search setup allows the boost to be changed from query to query, whereas this approach sets a fixed boost for each field.
I wasn't able to make wildcard search work in a native query, so I had to use the examine api to make queries when I needed to support wildcards using the MultipleCharacterWildcard extension. See this thread for a simple example of that. Lost some of the flexibility I had when using native queries, but it's a non issue most of the time.
Is there a way to include a wildcard in an Examine NativeQuery call?
I've noticed that Examine strips out the wildcard indicator when using the NativeQuery method. For example, if I pass "someProperty:test*^5" to it, it gets converted to "someProperty:test^5." While adding the wildcard via the Examine MultipleCharacterWildcard string extension does work, I'm not aware of any way of combining that with boosting.
Is there a setting I'm missing, or is this a limitation of Examine?
I honestly can't tell you if there is a way to use it in the NativeQuery, but if you have another way to do the query you want I would go with that and do the boosting when creating the index.
Like this:
I wasn't aware that we could do that. Good to know. While that does work around the issue, it's not quite what I'm looking for, as my search setup allows the boost to be changed from query to query, whereas this approach sets a fixed boost for each field.
Hello Jesse, Did you find any solution to this problem? Thanks!
I wasn't able to make wildcard search work in a native query, so I had to use the examine api to make queries when I needed to support wildcards using the MultipleCharacterWildcard extension. See this thread for a simple example of that. Lost some of the flexibility I had when using native queries, but it's a non issue most of the time.
is working on a reply...