Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
lucene_tool.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
22 #ifndef LUCENE_TOOL_H_
23 #define LUCENE_TOOL_H_
24 
25 #include "uuid_defs.h"
26 
27 #include "lucene_library.h"
28 #include "typedefs.h"
29 #include "string_hash_table.h"
30 #include "linked_list.h"
31 #include "lucene_document.h"
32 #include "grassroots_server.h"
33 #include "service_job.h"
34 
35 
40 typedef enum
41 {
48 
54 
59 } QueryMode;
60 
67 typedef struct LuceneTool
68 {
69  char *lt_name_s;
70 
71  const char *lt_index_class_s;
72 
73  const char *lt_search_class_s;
74 
75  const char *lt_delete_class_s;
76 
77  const char *lt_classpath_s;
78 
79  const char *lt_index_s;
80 
81  const char *lt_taxonomy_s;
82 
84 
85  const char *lt_facet_key_s;
86 
88 
90 
92 
94 
96 
98 
99 } LuceneTool;
100 
101 
102 
103 #ifndef DOXYGEN_SHOULD_SKIP_THIS
104 
105 #ifdef ALLOCATE_LUCENE_TOOL_CONSTANTS
106  #define LUCENE_TOOL_PREFIX GRASSROOTS_LUCENE_API
107  #define LUCENE_TOOL_VAL(x) = x
108 #else
109  #define LUCENE_TOOL_PREFIX extern GRASSROOTS_LUCENE_API
110  #define LUCENE_TOOL_VAL(x)
111 #endif
112 
113 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
114 
115 
116 
117 LUCENE_TOOL_PREFIX const char *LT_EXACT_SEARCH_OP_S LUCENE_TOOL_VAL ("=");
118 
119 LUCENE_TOOL_PREFIX const char *LT_NUM_TOTAL_HITS_S LUCENE_TOOL_VAL ("total_hits");
120 
121 LUCENE_TOOL_PREFIX const char *LT_HITS_START_INDEX_S LUCENE_TOOL_VAL ("from");
122 
123 LUCENE_TOOL_PREFIX const char *LT_HITS_END_INDEX_S LUCENE_TOOL_VAL ("to");
124 
125 LUCENE_TOOL_PREFIX const char *LT_FACETS_S LUCENE_TOOL_VAL ("facets");
126 
127 
132 LUCENE_TOOL_PREFIX const char *LUCENE_ID_S LUCENE_TOOL_VAL("id");
133 
134 
135 #ifdef __cplusplus
136 extern "C"
137 {
138 #endif
139 
151 
152 
160 
161 
162 
163 
174 GRASSROOTS_LUCENE_API bool SearchLucene (LuceneTool *tool_p, const char *query_s, LinkedList *facets_p, const char *search_type_s, const uint32 page_index, const uint32 page_size, const QueryMode qm);
175 
176 
187 GRASSROOTS_LUCENE_API OperationStatus IndexLucene (LuceneTool *tool_p, const json_t *data_p, bool update_flag);
188 
189 
198 GRASSROOTS_LUCENE_API OperationStatus DeleteLucene (LuceneTool *tool_p, const char *query_s, const QueryMode qm);
199 
200 
201 
202 GRASSROOTS_LUCENE_API OperationStatus ParseLuceneResults (LuceneTool *tool_p, const uint32 from, const uint32 to, bool (*lucene_results_callback_fn) (const json_t *document_p, const uint32 index, void *data_p), void *data_p);
203 
204 
216 GRASSROOTS_LUCENE_API bool SetLuceneToolOutput (LuceneTool *tool_p, char *output_s);
217 
218 
219 GRASSROOTS_LUCENE_API bool SetLuceneToolName (LuceneTool *tool_p, const char *name_s);
220 
221 
223 
224 
225 GRASSROOTS_LUCENE_API bool AddLuceneFacetResultsToJSON (LuceneTool *tool_p, json_t *metadata_p);
226 
227 
228 
229 GRASSROOTS_LUCENE_API bool AddFacetResultToLucene (LuceneTool *tool_p, const char *name_s, const uint32 count);
230 
231 
232 GRASSROOTS_LUCENE_API OperationStatus IndexData (struct ServiceJob *job_p, const json_t *data_to_index_p, const char *job_name_s);
233 
234 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* LUCENE_TOOL_H_ */
lucene_document.h
LuceneTool::lt_facet_results_p
LinkedList * lt_facet_results_p
Definition: lucene_tool.h:97
LuceneTool::lt_num_total_hits
uint32 lt_num_total_hits
Definition: lucene_tool.h:89
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
LuceneTool::lt_facet_key_s
const char * lt_facet_key_s
Definition: lucene_tool.h:85
LuceneTool::IndexLucene
GRASSROOTS_LUCENE_API OperationStatus IndexLucene(LuceneTool *tool_p, const json_t *data_p, bool update_flag)
Index data in Lucene.
LuceneTool::lt_index_s
const char * lt_index_s
Definition: lucene_tool.h:79
GRASSROOTS_LUCENE_API
#define GRASSROOTS_LUCENE_API
Definition: lucene_library.h:46
grassroots_server.h
SetLuceneToolName
GRASSROOTS_LUCENE_API bool SetLuceneToolName(LuceneTool *tool_p, const char *name_s)
LuceneTool::lt_working_directory_s
const char * lt_working_directory_s
Definition: lucene_tool.h:83
LuceneTool
A Tool for running Lucene jobs.
Definition: lucene_tool.h:67
uuid_defs.h
LuceneTool::SearchLucene
GRASSROOTS_LUCENE_API bool SearchLucene(LuceneTool *tool_p, const char *query_s, LinkedList *facets_p, const char *search_type_s, const uint32 page_index, const uint32 page_size, const QueryMode qm)
Run a Lucene Search.
typedefs.h
SetLuceneToolId
GRASSROOTS_LUCENE_API void SetLuceneToolId(LuceneTool *tool_p, uuid_t id)
ParseLuceneResults
GRASSROOTS_LUCENE_API OperationStatus ParseLuceneResults(LuceneTool *tool_p, const uint32 from, const uint32 to, bool(*lucene_results_callback_fn)(const json_t *document_p, const uint32 index, void *data_p), void *data_p)
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
LuceneTool::lt_index_class_s
const char * lt_index_class_s
Definition: lucene_tool.h:71
AddFacetResultToLucene
GRASSROOTS_LUCENE_API bool AddFacetResultToLucene(LuceneTool *tool_p, const char *name_s, const uint32 count)
string_hash_table.h
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
LuceneTool::lt_hits_from_index
uint32 lt_hits_from_index
Definition: lucene_tool.h:91
QM_TERMS
Create one or more Term/Phrase queries and programmatically combine them into a BooleanQuery.
Definition: lucene_tool.h:53
service_job.h
GrassrootsServer
Definition: grassroots_server.h:45
QueryMode
QueryMode
The internal method that the Lucene engine will use to build the query to search for.
Definition: lucene_tool.h:40
IndexData
GRASSROOTS_LUCENE_API OperationStatus IndexData(struct ServiceJob *job_p, const json_t *data_to_index_p, const char *job_name_s)
LuceneTool::DeleteLucene
GRASSROOTS_LUCENE_API OperationStatus DeleteLucene(LuceneTool *tool_p, const char *query_s, const QueryMode qm)
Delete data in Lucene.
LuceneTool::lt_search_class_s
const char * lt_search_class_s
Definition: lucene_tool.h:73
linked_list.h
A doubly-linked list.
QM_PARSER
Use a org.apache.lucene.queryparser.classic.QueryParser to build the query by passing it a string and...
Definition: lucene_tool.h:47
QM_NUM_MODES
The number of different QueryModes.
Definition: lucene_tool.h:58
AddLuceneFacetResultsToJSON
GRASSROOTS_LUCENE_API bool AddLuceneFacetResultsToJSON(LuceneTool *tool_p, json_t *metadata_p)
LuceneTool::lt_taxonomy_s
const char * lt_taxonomy_s
Definition: lucene_tool.h:81
LuceneTool::AllocateLuceneTool
GRASSROOTS_LUCENE_API LuceneTool * AllocateLuceneTool(GrassrootsServer *grassroots_p, uuid_t id)
Allocate a LuceneTool to run searches with.
LuceneTool::lt_output_file_s
char * lt_output_file_s
Definition: lucene_tool.h:87
LuceneTool::lt_name_s
char * lt_name_s
Definition: lucene_tool.h:69
LuceneTool::SetLuceneToolOutput
GRASSROOTS_LUCENE_API bool SetLuceneToolOutput(LuceneTool *tool_p, char *output_s)
Set the name of the output file that the LuceneTool will write its results to.
LuceneTool::lt_delete_class_s
const char * lt_delete_class_s
Definition: lucene_tool.h:75
LuceneTool::lt_hits_to_index
uint32 lt_hits_to_index
Definition: lucene_tool.h:93
LuceneTool::lt_id
uuid_t lt_id
Definition: lucene_tool.h:95
LuceneTool::lt_classpath_s
const char * lt_classpath_s
Definition: lucene_tool.h:77
LuceneTool::FreeLuceneTool
GRASSROOTS_LUCENE_API void FreeLuceneTool(LuceneTool *tool_p)
Free a LuceneTool.
LuceneTool::LUCENE_TOOL_VAL
const LUCENE_TOOL_PREFIX char *LUCENE_ID_S LUCENE_TOOL_VAL("id")
The identifier used to uniquely specify a Lucene document.
uuid_t
Definition: windows_uuid.h:43
lucene_library.h