Copied to clipboard

Flag this post as spam?

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


  • pvassalo 21 posts 28 karma points
    Oct 14, 2011 @ 13:14
    pvassalo
    0

    Examine wildcard

    Hello all!

     

    i have this kind of code on my project:

    =======================================

    string term = "word1 word2";

    ISearchCriteria filter = searchCriteria

                        .OrderBy(new[]{"title"})

                        .Or().Field("title", term)

                        .Or().Field("summary", term)                    

                        .Or().Field("textBody", term)

                        .Or().NodeName(term)

                        .Compile();

     

    searchProvider.Search(filter);

    ==============================

     

    This returns all the contents that have "word1 word2" together.

    But I need to return contents that have word1 and word2 even if they are not together or even if just one of them is found... How can I do this?

     

    I hope I was clear about this

     

    thanks in advance!

    Pedro

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Oct 14, 2011 @ 14:19
    Dan Diplo
    0

    You might need to stop using the fluent API and go back to using raw Lucene query syntax.

    You can build a raw query something like this (where "query" is the string containing your query):

    SearchProvider.Search(SearchProvider.CreateSearchCriteria().RawQuery(query));
  • pvassalo 21 posts 28 karma points
    Oct 14, 2011 @ 16:14
    pvassalo
    0

    Thanks for the reply!

    Yes I was using the raw query before, but went for the  "fluent" API because I needed to "boost" some fields... Can I boost field on the rawquery too?

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Oct 14, 2011 @ 16:47
    Dan Diplo
    0

    Yeah, sure you can - see http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boosting a Term 

    and you want the term "jakarta" to be more relevant boost it using the ^ symbol along with the boost factor next to the term. You would type:

    jakarta^4 apache
  • pvassalo 21 posts 28 karma points
    Oct 14, 2011 @ 16:48
    pvassalo
    0

    That helps a lot! thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies