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 711701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:45:54+00:00 2026-05-14T04:45:54+00:00

I am trying to put together a test case for using Lucene.NET on one

  • 0

I am trying to put together a test case for using Lucene.NET on one of our websites. I’d like to do the following:

Index in a single unique id.
Index across a comma delimitered string of terms or tags.

For example.

Item 1:
Id = 1
Tags = Something,Separated-Term

I will then be structuring the search so I can look for documents against tag i.e.

tags:something OR tags:separate-term

I need to maintain the exact term value in order to search against it.

I have something running, and the search query is being parsed as expected, but I am not seeing any results. Here’s some code.

My parser (_luceneAnalyzer is passed into my indexing service):

var parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_CURRENT, "Tags", _luceneAnalyzer);
parser.SetDefaultOperator(QueryParser.Operator.AND);
return parser;

My Lucene.NET document creation:

var doc = new Document();

var id = new Field(
    "Id",
    NumericUtils.IntToPrefixCoded(indexObject.id),
    Field.Store.YES,
    Field.Index.NOT_ANALYZED,
    Field.TermVector.NO);

var tags = new Field(
    "Tags",
    string.Join(",", indexObject.Tags.ToArray()),
    Field.Store.NO,
    Field.Index.ANALYZED,
    Field.TermVector.YES);

doc.Add(id);
doc.Add(tags);

return doc;

My search:

var parser = BuildQueryParser();
var query = parser.Parse(searchQuery);
var searcher = Searcher;

TopDocs hits = searcher.Search(query, null, max);
IList<SearchResult> result = new List<SearchResult>();
float scoreNorm = 1.0f / hits.GetMaxScore();

for (int i = 0; i < hits.scoreDocs.Length; i++)
{
    float score = hits.scoreDocs[i].score * scoreNorm;
    result.Add(CreateSearchResult(searcher.Doc(hits.scoreDocs[i].doc), score));
}

return result;

I have two documents in my index, one with the tag “Something” and one with the tags “Something” and “Separated-Term”. It’s important for the – to remain in the terms as I want an exact match on the full value.

When I search with “tags:Something” I do not get any results.

Question

What Analyzer should I be using to achieve the search index I am after?
Are there any pointers for putting together a search such as this?
Why is my current search not returning any results?

Many 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-05-14T04:45:54+00:00Added an answer on May 14, 2026 at 4:45 am

    It appears you can add multiple fields with the same name to a document so I changed my code to:

    foreach (string tag in vehicle.Tags)
    {
        var tags = new Field(
            TAGS,
            tag,
            Field.Store.YES,
            Field.Index.ANALYZED,
            Field.TermVector.YES);
    
        doc.Add(tags);
    }
    

    I can now search by single or multiple tags in the “Tags” field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put together a horizontal content slider using JQueryMobile. The following code
I'm trying to put together a layout using Bootstrap that resembles your typical OS
I'm trying to put together a presentation for my local .NET user group on
I'm trying to put together a class to handle Ipc between processes using anonymous
I am trying to put together some accessibility examples for work. One of the
I'm trying to get client-side validation running. I've put together a very simple test
I'm learning AJAX and jQuery and I'm trying to put together a simple test
I'm trying to look into wxPython and sizers, and I put together the following
I trying to put together an Android app that will take a picture and
I'm trying to put together a script to monitor the MSMQ on a server.

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.