Lucene Index filter

Posted on 2007-08-10
Last Modified: 2013-11-05

I want to filter on lucene index.
where in the results should not contain array of string. The array can have length upto 10000. (Array string are input from user at runtime so we can not cache or store.)
How do i add filter.
If i add
NOT Name:xyz AND NOT Name:abc AND NOT Name:pqr .....

The query length will be too large.

Any suggestion for optimizing this.

    LVL 6

    Accepted Solution

    Just a thought, it might help you:

    Build a filter programatically:

    BooleanFilter booleanFilter = new BooleanFilter();
    //add conditions
    booleanFilter.add(new FilterClause(getTermsFilter("Name","abc"),BooleanClause.Occur.MUST_NOT));
    booleanFilter.add(new FilterClause(getTermsFilter("Name","pqr"),BooleanClause.Occur.MUST_NOT));

    //perform filtering
    BitSet bits = booleanFilter.bits(reader);


    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now