1

My client needs me to write a speak app that can do a search where they can type in whatever field they want to equal a value in the search bar. Is there a way to do a search against Lucene to within Sitecore to allow a dynamic field?

3

Maybe I am misunderstanding you, but do you just want to pass in the field as a name and the value to search? Or is this deeper and you want the full speak pipelines for doing this search?

var yourField = "content";
var yourValue = "hello";

using (var searchContext = ContentSearchManager.GetIndex("sitecore_web_index").CreateSearchContext())
{
    var query = searchContext.GetQueryable<SearchResultItem>().Where(x => x[yourField] == yourValue);

    if (result != null)
    {
        var results = query.GetResults();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.