Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is an example of how to search the index. We have 4 query filters.
Give me all entries where assetId is not empty

...

Then give me all assets, that are not crops.

...

The give me only the assettype 4, which is images.

...

, no crop assets, only assets of assettype 4 (images) and last we freetext search the title.

Code Block
languagec#
var index = ContentSearchManager.GetIndex("dfs_contentsearch_master_index");
using (var searchContext = index.CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
{
    var queryable = searchContext.GetQueryable<AssetResultItem>().Where(q => q.AssetId != string.Empty);
    queryable = queryable.Where(q => q.Derivedfrom == "0");
    queryable = queryable.Where(q => q.Assettype == "4");
    queryable = queryable.Where(q => q.Title.Contains(freeText));

    var res = queryable.GetResults();

    foreach (var searchResult in res)
    {
        renderList.assets.Add(new asset()
        {
            htmlTag = searchResult.Document.Thumbhtmltag,
            title = searchResult.Document.Title
        });
    }
}

Here is an example of the Example of a website using the search.

...

You can download all the configuration and c# files here:

...