Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • xumix 17 posts 109 karma points c-trib
    Aug 05, 2014 @ 12:31

    Can't get proper Lucene query for my search

    The basic thing is: I want to search for a phrase and want all of the words to present in the searched document.

    The query must look like: (+field1: my + field1: phrase) or (+field2: my + field2: phrase) or (+field3: my + field3: phrase) etc..

    How do I make this query with Lucene?


  • xumix 17 posts 109 karma points c-trib
    Aug 05, 2014 @ 12:34

    Update: I've managed to do this with:

    var sc = CreateSearchCriteria(string.Empty, BooleanOperation.Or);

    var strArray = searchText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(f => f.Fuzzy(0.8f)).ToArray();

    var searchFields = GetSearchFields();
    foreach (var field in searchFields)
    sc.GroupedAnd(Enumerable.Repeat(field, strArray.Length), strArray);

    var siteResults = base.Search(sc, 100);
Please Sign in or register to post replies

Write your reply to: