Main Page | Data Structures | Directories | File List | Data Fields | Globals

lcn_query.h

Go to the documentation of this file.
00001 /* Copyright 2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /**
00018  * @file lcn_query.h
00019  * @brief Routines for working with queries
00020  */
00021 
00022 #ifndef _LCN_QUERY_H
00023 #define _LCN_QUERY_H
00024 
00025 #include "lcn_types.h"
00026 #include "lcn_scorer.h"
00027 #include "lcn_term.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif /* __cplusplus */
00032 
00033 /** Abstract query object. */
00034 typedef struct lcn_query_t lcn_query_t;
00035 
00036 /** Create a @a query that matches @a term, allocated in @a pool. */
00037 lcn_error_t *
00038 lcn_term_query_create (lcn_query_t **query,
00039                        lcn_term_t *term,
00040                        apr_pool_t *pool);
00041 
00042 /** Create a @a query that matches a number of other queries, each of which
00043  * either MUST occur, SHOULD occur, or MUST NOT occur in the documents matched,
00044  * the query is allocated in @a pool.
00045  */
00046 lcn_error_t *
00047 lcn_boolean_query_create (lcn_query_t **query, apr_pool_t *pool);
00048 
00049 /** An indication of what requirement is placed on a particular part of a
00050  * boolean query.
00051  */
00052 typedef enum {
00053   LCN_MUST,    /**< The query must match */
00054   LCN_SHOULD,  /**< At least one of the queries with this occur must match */
00055   LCN_MUST_NOT /**< The query must not match */
00056 } lcn_boolean_clause_occur_t;
00057 
00058 /** Add @a clause to @a query, with @a occur as the specification for whether
00059  * it is required or not.
00060  *
00061  * @note all clauses that are added to @a query must be allocated from a pool
00062  * that lives at least as long as the pool used to allocate @a query, or the
00063  * behavior is undefined.
00064  */
00065 lcn_error_t *
00066 lcn_boolean_query_add (lcn_query_t *query,
00067                        lcn_query_t *clause,
00068                        lcn_boolean_clause_occur_t occur);
00069 
00070 /** Return @a weight's underlying query. */
00071 lcn_query_t * lcn_weight_query (lcn_weight_t *weight);
00072 
00073 /** Return the value of @a weight. */
00074 float lcn_weight_value (lcn_weight_t *weight);
00075 
00076 #if NOTYET
00077 /** Return the sum of the squared weight sof contained query clauses. */
00078 lcn_error_t *
00079 lcn_weight_sum_of_squared_weights (float *sum, lcn_weight_t *weight);
00080 
00081 /** Assign a query normalization factor @a norm to this @a weight. */
00082 lcn_error_t * lcn_weight_normalize (lcn_weight_t *weight, float norm);
00083 
00084 /* XXX leaving out lcn_weight_explain for now... */
00085 #endif
00086 
00087 /** Create an @a weight from @a query. */
00088 lcn_error_t *
00089 lcn_query_weight (lcn_weight_t **weight,
00090                   lcn_query_t *query,
00091                   apr_pool_t *pool);
00092 
00093 /** Return a @a scorer for @a weight run over @a index, allocated in
00094  * @a pool.
00095  *
00096  * @note the Java Lucene version of this stuff works on a Weight, not a
00097  * Query, but that's mainly because you are supposed to be able to reuse
00098  * a Query, so we can make that split later.
00099  */
00100 lcn_error_t *
00101 lcn_weight_scorer (lcn_scorer_t **scorer,
00102                    lcn_weight_t *weight,
00103                    lcn_index_t *index,
00104                    apr_pool_t *pool);
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif /* __cplusplus */
00109 
00110 #endif /* _LCN_QUERY_H */

Generated on Sat Mar 26 08:12:11 2005 for Lucene4c by  doxygen 1.4.0