Network retrieval is everywhere! Whether it is an obvious search engine, or forum, online shopping catalog, etc., frequently use network retrieval. Therefore, we "Network Retrieval" here define that users submit certain retrieval conditions (such as keyword information) into the retrieval app on the server, and obtain the results returned and rendered.
Search mode
In general, when the result set is too large (frequent cases often appear very large), the policy of paging data is taken, that is, each time the small part of the result set is similar, by "Previous", "Next Page "to view more results. The user's expectation is that the submitted retrieval can get a response quickly, and it can also get a response when "the previous page", "next page" operation. Therefore, the key to the problem is to obtain the result data required for each time according to the recording start position and the number of records that require the record. There are currently some ways to use.
1) The search condition submitted by the user is re-executed each time, and then obtains a subset of the retrieval result set. The user's search condition is saved in a cookie, session, or HTML form hidden element (")). Since the retrieval operation requires a lot of use of the server and database resources, each execution retrieval will undoubtedly increase this burden, reduce the efficiency of retrieval applications.
2) Remove all of the retrieval results into a large object, the object implements various operations of the record. At the same time, if the object is cacked on the server, then the subsequent flip operations do not need to re-execute the retrieval conditions and acquire the subset of the results directly from the object. However, the operation of saving all the search results to the object is complicated, and if the result set is large, it means that the object is cached, and the object needs to take up a lot of valuable server resources. At the same time, the display speed of the first result may not be satisfactory.
3) Once the result subset of "a few pages" is obtained and saved to the object and cache it. If the user's "next page" operation exceeds the current object provided, the retrieval condition is performed again, and the condition is obtained again. A few pages "and save them in the same object. Considering this situation is that the user may only view some of the startings, and few records are rarely recorded. From this sense, it is not a good way. However, if you move to an unacceptable record, you must re-execute the query while reducing the speed of the result display.
4) When the search is first executed, you will first uniquely determine the number of each record (such as the primary key) to the object and cache it, and the request to each page will first identify the condition in the cached primary key object. The primary key collection, re-establish the query statement (using the IN keyword) to obtain the record you need, which can accurately define the range of retrieved retrieval each time, and is only the required data. Of course, if a table does not exist such a unique number or the primary key.
5) In some search applications, such as the posts of the forum, you can save some posts in a public cache area, when the user requests a query executed, only the primary key of the post, according to these primary keys to the public buffer area Go to get records. If the record of the corresponding primary key does not exist, use the primary key to query the record while saving the record to the public buffer area. This method is suitable for most of the same cases of multiple users, as shown in the forum post.
6) If it is in the J2EE architecture, the Finder method using EJB can also return a collection of objects, and such an object encapsulates each recorded data. However, the generation of a large number of objects and existence is undoubtedly a huge consumption of server resources in server memory. Therefore, for the result set of a large number of records, the entity bean is used to represent the system resources and actually can't achieve too much benefits.
The key to network retrieval is to retrieve the execution efficiency, network transmission speed, and result set. In integrated, the mode of the network retrieval is to build a database, optimized SQL query statements that can be used by the database, execute and returned by the database, and then generate the display page based on these records. Therefore, in the intermediate layer and data layer, we focus on how to efficiently generate the result data required for each time; in the representation layer, the user needs to provide a friendly, convenient display, and operation interface.
The implementation mechanism uses the efficiency of various retrieval methods, and the cache of the result set object is feasible. In JDBC2.0, support the scrollable result set can be arbitrarily acquired a subset of the result set. At the same time, it can be specified that the number of returns capable of being cached is not required to return all records (for paging operations, the function has actual meaning), and when new records are required, then to the database and Replace the old record in the cache. However, each database vendor is implemented in the respective different forms of JDBC2.0, so the efficiency is different. Oracle is perfect in this regard. The specific process of retrieval operation is: the user is submitted to the retrieval handler (such as a searchservlet) by retrieving a search page (such as search.jsp), submits the data submitted by the search handler (such as searchServlet) and constructs A reasonable SQL query statement; the SQL query statement is executed by the retrieval executor (such as localEngine), and the result set will be cached, and the retrieval result page (such as searchResult.jsp); Submit request to the result handler (such as searchResultServlet) to get the required data, format and display information. Figure 1: The key to searching sequence diagram network retrieval is two aspects: the execution and results of the retrieval. If you consider from the user's point of view, it is more concerned about the accuracy of the search, the result of the user's friendlyness and retrieval response speed. The results of XML binding data binding show that XML has great potential for data performance and data exchange. However, directly rendering XML data is not the best mode, and you need to use the browser's function to improve data display. An effective way to transmit XML is to utilize the XMLHTTP object in the MSXML interpreter, which allows you to open a HTTP connection on the server, send some data and retrieve some data, and all this is very small The segment script can be implemented. Using XMLHTTP objects is usually XML data exchange, but other formatted data is also allowed. When making this series, you don't need to load the current web page. Users don't even know what the background is doing, the webpage doesn't have to re-refresh the new data has been obtained. When the client's request is sent to the server, the returned data can be accepted by the XMLHTTP object. Use the data island to embed the XML data returned to the page. Extended Markup Language XML Use a standard way to describe and exchange structured data; XML data is performed in an open, text-based format, and transmitted through standard HTTP protocols. The characteristics of XML itself determine that it is born is a flexible powerful data source object (DSO). IE4.0 uses Java Applet to implement XML DSO; IE5.0 supports Data Island, and users can use the data defined by the