Try our conversational search powered by Generative AI!

Get no Results on GetPropertyValue

Vote:
 

I want to search on pages with GetPropertyValue but I don't get any result with:

var results =
            SearchClient.Instance.Search()
            .Filter(p => p.GetPropertyValue("Name").Exists())
.GetContentResult();

But with this I get results:

var results =
            SearchClient.Instance.Search<>PageData>()
            .Filter(p => p.Name.Exists())
.GetContentResult();

Is this a Bug?
#118944
Mar 18, 2015 3:09
Vote:
 

Hello Aldo,

GetPropertyValue is an extension method that Filter function does not support. Under the hood, an expression passed to the Filter function is translated into ElasticSearch query, so there are certain limitations on what can be used in Filter. 

if you need to speicfy a property name dynamically, you can use ExistsFilter:

var results = searchClient.Search<PageData>()
    .Filter(new ExistsFilter(TypeSuffix.GetSuffixedFieldName("Name", typeof(String))))
    .GetContentResult();

Note that you need to speicfy the property type as a second argument of the GetSuffixedFieldName function.

#118983
Mar 18, 2015 11:58
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.