Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:24:43+00:00 2026-06-09T15:24:43+00:00

the below way i did the search with lucene.net. this routine search multiple word

  • 0

the below way i did the search with lucene.net. this routine search multiple word against all index field called “Title”, “Description”, “Url”, “Country” .

i need to know how can i give a condition like where country=’UK’ or country=’US’

i want that multiple word should be search like below but i want to add one more clause that when country is UK. so please guide me what to add in my code.

 if (!string.IsNullOrEmpty(multiWordPhrase))
    {

        string[] fieldList = { "Title", "Description", "Url" };
        List<BooleanClause.Occur> occurs = new List<BooleanClause.Occur>();
        foreach (string field in fieldList)
        {
            occurs.Add(BooleanClause.Occur.SHOULD);
        }

        searcher = new IndexSearcher(_directory, false);
        Query qry = MultiFieldQueryParser.Parse(Version.LUCENE_29, multiWordPhrase, fieldList, occurs.ToArray(), new StandardAnalyzer(Version.LUCENE_29));
        TopDocs topDocs = searcher.Search(qry, null, ((PageIndex + 1) * PageSize), Sort.RELEVANCE);
        ScoreDoc[] scoreDocs = topDocs.ScoreDocs;
        int resultsCount = topDocs.TotalHits;
        list.HasData = resultsCount;
        StartRecPos = (PageIndex * PageSize) + 1;
        if (topDocs != null)
        {
            for (int i = (PageIndex * PageSize); i <= (((PageIndex + 1) * PageSize)-1) && i < topDocs.ScoreDocs.Length; i++)
            {
                Document doc = searcher.Doc(topDocs.ScoreDocs[i].doc);
                oSr = new Result();
                oSr.ID = doc.Get("ID");
                oSr.Title = doc.Get("Title");
                oSr.Description = doc.Get("Description");
                //oSr.WordCount = AllExtension.WordCount(oSr.Description, WordExist(oSr.Title, multiWordPhrase));
                string preview =
                oSr.Description = BBAReman.AllExtension.HighlightKeywords(oSr.Description, multiWordPhrase);  //sr.Description;
                oSr.Url = doc.Get("Url");
                TmpEndRecpos++;
                list.Result.Add(oSr);
            }
        }

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:24:44+00:00Added an answer on June 9, 2026 at 3:24 pm

    Look up BooleanQuery

    if (!string.IsNullOrEmpty(multiWordPhrase))
    {
       BooleanQuery bq = new BooleanQuery();
    
       string[] fieldList = { "Title", "Description", "Url" };
       List<BooleanClause.Occur> occurs = new List<BooleanClause.Occur>();
       foreach (string field in fieldList)
       {
          occurs.Add(BooleanClause.Occur.SHOULD);
       }
       Query qry = MultiFieldQueryParser.Parse(Version.LUCENE_29, multiWordPhrase, fieldList, occurs.ToArray(), new StandardAnalyzer(Version.LUCENE_29));
    
    
       bq.Add(qry,BooleanClause.Occur.Must);
    
       //this is the country query (modify the Country field name to whatever you have)
       string country = "UK";
       Query q2 = new QueryParser(Version.LUCENE_CURRENT, "Country", analyzer).parse(country);
       bq.Add(q2,BooleanClause.Occur.Must);
       searcher = new IndexSearcher(_directory, false);
    
       TopDocs topDocs = searcher.Search(bq, null, ((PageIndex + 1) * PageSize), Sort.RELEVANCE);
       ScoreDoc[] scoreDocs = topDocs.ScoreDocs;
       int resultsCount = topDocs.TotalHits;
       list.HasData = resultsCount;
       StartRecPos = (PageIndex * PageSize) + 1;
       if (topDocs != null)
       {
         //loop through your results
    
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to install python below way. But this did not work. This take
What is a good way to give the input field below the three characteristics
I'm looking for a way to create a dynamic list below a text field
i am hitting this url: http://www.google.co.uk/search?q=online stores uk&hl=en&cr=countryUK%7CcountryGB&as_qdr=all&tbs=ctr:countryUK Basically i get the ppcUrls, it
Is there a best (see below) way to append two byte arrays in C#?
i develop a calling program in the below way. my main aim is enter
Below is my way, albeit a basic way of creating a Decision Tree...The problem
Is there any way to do things the short and easy way like below?
Lets say I have model inheritance set up in the way defined below. class
Would following the table below be the best way of determining the access type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.