I haven't engaged in release e.net for a long time. Today, I have sorted out hard disk data and found that I wrote a search engine framework, which contains a document to sort out some knowledge points, and I sorted out some of them and published them, we hope this will be helpful to those who have studied paie.net:
Q: How do I implement the percentage correlation value of the search result in lucene.net?
A:
Hits result = searcher. Search (Q );
Float score = result. score (n); // n indicates the document sequence number of the query result. The returned result is a float value of <= 1f, which is expressed as a percentage string: score. tostring ("0% ");
Q: How can I change the location of the lock file stored by lucene.net through programming?
A:
By default, the lock file of e.net stores the temporary folder of the system. You can modify it using the following statement:
System. configuration. configurationsettings. deleettings. Add ("Lucene. net. lockdir", "your new lockdir ");
You can use fsdirectory. lock_dir to obtain the location (folder) where the lock file is stored)
Q: How can I determine if an index database is locked and how can I forcibly unlock it?
A:
For specific implementation, see the Lucene. net. Store. fsdirectory's obtain () (determine whether to lock) method and release () method (unlock)
Note: You can also refer to the islocked method.
Q: How can I implement joint search for Multiple indexes?
A:
Indexsearcher [] searchers = new indexsearcher [2];
Searchers [0] = new indexsearcher (dir1 );
Searchers [1] = new indexsearcher (dir2 );
Multisearcher searcher = new multisearcher (searchers); // or parallelmultisearcher searcher = new parallelmultisearcher (searchers );
Searcher. Search (query );
The difference between parallelmultisearcher and multisearcher is that the former opens a separate thread for each index and synchronously searches in multiple threads; the latter searches one by one and then merges the data;
Therefore, parallelmultisearcher is the slowest index in the total search time, And multisearcher is the sum of all indexes in the total search time;
Q: How can I search results?
A:
* Method 1: Use cachingwrapperfilter. You cannot search results infinitely ":
Queryparser parser = new queryparser ("content", analyzer );
Query currentquery = parser. parse (currentkeyword );
Query oldquery = parser. parse (oldkeyword );
Queryfilter oldfilter = new queryfilter (oldquery );
Cachingwrapperfilter filter = new cachingwrapperfilter (oldfilter );
Indexsearcher searcher = new indexsearcher (indexdir );
Hits result = searcher. Search (currentquery, filter );
* Method 2: Send the booleanquery with multiple query keywords as and or directly construct the query sytax to queryparser, which can implement an infinitely "search in results".
Q: What does booleanquery. maxclausecount mean?
A:
Maximum number of queries added to booleanquery. The default value is 1024. If this value is exceeded, A toomanyclses exception is thrown. You can use booleanquery. setmaxclausecount (INT) to set a new value.
Note: The meaning is not clear.
Q: How can I determine whether an index library exists?
A:
String indexpath = "Your indexpath"; // INDEX DIRECTORY
If (system. Io. Directory. exists (indexpath) & system. Io. file. exists (path. Combine (indexpath, "segments ")
// Exists
Else
// Does not exist
Of course there are more direct methods
If (Lucene. net. Index. indexreader. indexexists (indexpath ))
// Exists
Else
// Does not exist
The internal implementation method of Lucene. net. Index. indexreader. indexexists is similar to the above. Of course, Lucene. net. Index. indexreader. indexexists is more reliable.