Initial Exploration of e.net,

Source: Internet
Author: User
Tags createindex

Initial Exploration of e.net,
Introduction

When analyzing client search projects developed by colleagues, I noticed that the key to search is indexing, And when I mention indexing, I have to mention e.net. The idea is to write the search content into the index, the client directly searches for indexes when searching by itself or other machines in the LAN to view your shared information.

Some key classes are focused on when you first look at paie.net:

A): IndexReader reads the index.

B): IndexWriter creates an index.

C): StandardAnalyzer is used for Word Segmentation and parsing. Many applications are used. When parsing English and Chinese characters, StandardAnalyzer is split into a single letter or Chinese character, if PanGuAnalyzer [pangu analysis parsing] is used, it is split into phrase searches.

D): IndexSearcher index search.

 

Effect

1. index file when writing content

 

2. Search Results After Entering keywords

 

Code
Static void Main (string [] args) {// CreateIndex ("Oracle", "Oracle, full name: Oracle Co., Ltd. (Oracle software system Co., Ltd ), is the world's largest enterprise software company headquartered in Redwood Beach, California. Officially entered the Chinese market in 1989. In 2013, oracle surpassed IBM and became the world's second largest software company after Microsoft "), ReadIndex (" oracle Company IBM "), and Console. readKey ();} private static void CreateIndex (string title, string content) {string indexpath = AppDomain. currentDomain. baseDirectory + "IndexData"; FSDirectory directory = FSDirectory. open (new DirectoryInfo (indexpath), new NativeFSLockFactory (); bool isExist = IndexReader. indexExists (directory); // determines whether the index exists if (isExi St) {if (IndexWriter. isLocked (directory) // you need to unlock {IndexWriter when writing an index. unlock (directory) ;}} IndexWriter indexWriter = new IndexWriter (directory, new StandardAnalyzer (),! IsExist, IndexWriter. maxFieldLength. UNLIMITED); Document document = new Document (); Field f1 = new Field ("title", title, Field. store. YES, Field. index. TOKENIZED); Field f2 = new Field ("content", content, Field. store. YES, Field. index. TOKENIZED); document. add (f1); document. add (f2); indexWriter. addDocument (document); indexWriter. optimize (); indexWriter. close ();} private static void ReadIndex (string keywords) {string indexpath = AppDomain. currentDomain. baseDirectory + "IndexData"; string title = ""; string content = ""; StandardAnalyzer analyzer = new StandardAnalyzer (); // word segmentation IndexSearcher searcher = new IndexSearcher (indexpath ); // index search -- input the index file path // MultiFieldQueryParser multi-field search. Multiple content to be parsed can be input at a time, // if you need to input one at a time, use QueryParse MultiFieldQueryParser parser = new MultiFieldQueryParser (new string [] {"title", "content"}, analyzer); Query query Query = parser. parse (keywords); // converts it to the internal query object Hits hits = searcher. search (query); // execute the Search for (int I = 0; I 

 


Lucenenet: How can I increase the query speed with tens of millions of indexes? Is there a good way to recommend a few books or study them together?

Faster e.net improves index multi-folder search by dropping only the search results in the folder
 
Lucenenet filters search results or

/// Set the weight based on the document
// Random rd = new Random ();
// Int I = rd. Next (10 );
// Doc. SetBoost (I );

/// Set the weight data based on the field
// Field d = new Field ("sort", myred ["sort"]. ToString (), Field. Store. YES, Field. Index. TOKENIZED );
// D. SetBoost (9F); // special note: float Decimals

----------------------------------------------------------------------
The preceding annotations show that they used random weights without business logic. You can add weights based on your requirements, such as determining whether the connections come from Sina, Sohu, and Baidu, these appropriate weights are higher. You can also control the weight of a url Based on the url external chain stored in your database and set the importance (rank value) of its content to ensure that some of the content with good experience is at the top, more algorithms depend on your own. What do you need?


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.