Copied to clipboard

Flag this post as spam?

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


  • Alessandro Bellisai 30 posts 120 karma points
    Jan 31, 2012 @ 23:49
    Alessandro Bellisai
    0

    Search with examine single phrase

    Hi 

    I'm developing a custom serach using examine via razor script.

    Some search criteria are selected form a drop down list and are composed by multiple words, for example "top crystal" 

    When i process all the criteria with a razor script, i iterate all the information and i build a dynamic lucene query that i execute with RowQuery.

    This is the code:

    var searcher = ExamineManager.Instance.SearchProviderCollection["ProdottiSearcher"];
    var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.And);

    var luceneString = "";

    if(!String.IsNullOrEmpty(searchTipologia)) {

         luceneString += "tipologia:" + searchTipologia + " ";
      

      if(!String.IsNullOrEmpty(searchLavabo))
      {
         luceneString += "lavabo:" + searchLavabo + " ";
      

      var query = searchCriteria.RawQuery(luceneString);
      var searchResults = searcher.Search(query);

    If i initialize searchTipologia with "top crystal" the result contains all the nodes with filedl tipologia that contains the word top and the word crystal, i wolud like to perform a query with the phrase "top crystal", how can i do that?

     

    Tahks in advice

    Alessandro

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    Feb 01, 2012 @ 09:19
    Markus Johansson
    0

    Hi!

    I use examine like this and that will match a phrase:

    var query = searchCriteria.Field("bodyText",searchString).Or().Field("nodeName", searchString).Or().Field("pageTitle",searchString).Compile();
    var searchResults = Searcher.Search(query);


    // Markus

Please Sign in or register to post replies

Write your reply to:

Draft