1.

Write the methods of creating a query?

Answer»

tion:This chapter describes the different query methods you can use in your ConText application. You can use these methods with text queries and theme queries. The following topics are covered:Selecting a Query MethodUsing Two-Step QueriesUsing One-Step QueriesUsing In-Memory QueriesCounting Query HitsSelecting a Query MethodEach of the query methods (two-step, one-step, and in-memory) provide advantages and disadvantages that you must consider when developing an application. The following table briefly describes each method and illustrates the various advantages and disadvantages to using each:Query Method  Use  Advantage  Disadvantage  One-step Used in SQL*Plus. Best suited for interactive queries. No pre-allocation of result tablesUses standard SQL statementsUses table and column namesQuery results returned in a single stepCan retrieve all hits at once Generally slower than two-step or in-memory queriesNo access to result tables Two-step Two-step queries are best suited for PL/SQL-based applications that require all the results to a query. Result tables can be manipulatedGenerally FASTER than one-step queries, especially for mixed queriesCan retrieve all hits at onceStructured data can be QUERIED as part of the CONTAINS (first step) Requires pre-allocation of result tablesUses policy namesRequires two STEPS to completeRequires join to base text table to return document details In-memory In-memory queries are best suited for PL/SQL-based applications that might generate large hitlists, but where only a small portion of the hits are required at a time, such as World Wide Web applications. No result tablesFaster RESPONSE time than two-step, since you need not retrieve all hits in the hitlist.Large hitlists generally faster than one-step and two-step queriesCan specify the number of hits returned Uses policy namesCannot retrieve all hits at onceWith small hitlists, performance improvement over two-step is negligibleRequires three steps, including a loop, to completeQueries for structured data must be performed separately and joined with in-memory resultsMax and first/next operators are not supported Using Two-Step QueriesTo perform a two-step query, do the following:Execute CTX_QUERY.CONTAINS. The procedure selects all documents that match the specified search criteria (query expression) and generates a score for each document.The document textkeys and scores are stored in the specified result table.Note:You must create the result table before you execute the CONTAINS procedure. Use a SELECT statement on the result table (and the base text table, if desired) to return the specified columns as a hitlist for the rows (documents) that satisfy the query expression.Two-Step Query ExampleThe following example shows a simple two-step query. The query uses a policy named ARTICLES_POL to search the text column in a table named TEXTTAB for any articles that contain the word petroleum. The CONTAINS procedure populates the CTX_TEMP results table with the document primary KEYS that satisfy the query.The select statement then joins the results in CTX_TEMP with TEXTAB to create a list of document titles ordered by score.



Discussion

No Comment Found