Lucene.Net is an open source project for Full-text indexing that is currently widely used in. NET environments and is used for full-text indexing in project development.
A few small problems in the development process are searching for multiple fields and multiple indexed directories.
1, a multiple-field search is to have more than one field of the content of the comparison search, similar concepts in SQL is select * from Table where a like '%query% ' or b '%query% '.
Single field query in Lucene.Net Everyone is familiar with the field content search
Query query = queryparser.parse (querystr, Content, New Chineseanalyzer ());
Hits Hits = searcher. Search (query);
A Multifieldqueryparser object is used for multiple field queries that inherit from query, and we want to search for field title,content.
String] fields = {"Content", "title"};
Query multiquery = Multifieldqueryparser.parse (querystr,fields,new chineseanalyzer ());
Hits Hits = searcher. Search (Multiquery);
2. Multiple indexed directories are to compare searches in multiple index directories, similar to the SELECT * FROM TableA Union SELECT * FROM TableB in SQL.
Indexsearcher[] Searchers = new indexsearcher[2];
Searchers[0] = new Indexsearcher (IndexPath0);
SEARCHERS[1] = new Indexsearcher (IndexPath1);
Multisearcher multisearcher = new Multisearcher (searchers);
Topdocs Multitopdocs = Multisearcher. Search (query, NULL, 1000);
The results of this search may have the same information, such as you have a similar information in multiple directories indexed, search results will appear many times the same information.
Another way to search is to use the Parallelmultisearcher object, which is inherited from Mulitsearcher.
Parallelmultisearcher parallelmultisearcher = new Parallelmultisearcher (searchers);
Topdocs Paralleltopdocs = Parallelmultisearcher. Search (query, NULL, 1000);
This search is a search for the results of the merger, eliminating duplicate information.