apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.59k stars 1.01k forks source link

Analyzer for preventing overload of search service by queries with common terms in large indexes [LUCENE-494] #1572

Closed asfimport closed 16 years ago

asfimport commented 18 years ago

An analyzer used primarily at query time to wrap another analyzer and provide a layer of protection which prevents very common words from being passed into queries. For very large indexes the cost of reading TermDocs for a very common word can be high. This analyzer was created after experience with a 38 million doc index which had a term in around 50% of docs and was causing TermQueries for this term to take 2 seconds.

Use the various "addStopWords" methods in this class to automate the identification and addition of stop words found in an already existing index.


Migrated from LUCENE-494 by Mark Harwood (@markharwood), 1 vote, resolved Feb 07 2008 Attachments: QueryAutoStopWordAnalyzer.java, QueryAutoStopWordAnalyzerTest.java

asfimport commented 16 years ago

Grant Ingersoll (@gsingers) (migrated from JIRA)

This seems generally useful and could go in contrib/analysis I suppose. Any thoughts on it, Mark, in hindsight? Do you still use it from time to time or do you now think there are better ways of doing it?

asfimport commented 16 years ago

Grant Ingersoll (@gsingers) (migrated from JIRA)

I think it makes sense to add this in after the 2.3 release.

asfimport commented 16 years ago

Mark Harwood (@markharwood) (migrated from JIRA)

I personally don't use this but others may. It was easier to solve my particular problem by adding stop words to my XSL query templates (I added support to the XMLQueryParser for the "FuzzyLikeThisQuery" tag to take stop words). This was more about ease of configuration in my particular app.

I know Nutch has something similar implemented elsewhere - maybe in the query parser.

I also had the notion that wrapping IndexReader to auto-cache TermDocs for super-popular terms using a BitSet would be a good way to avoid the IO overhead. This Bitset wouldn't help resolve positional queries e.g. phrase/span queries which need a TermPositions implementation but would work for straight TermQueries.

asfimport commented 16 years ago

Grant Ingersoll (@gsingers) (migrated from JIRA)

Committed, thanks Mark!