File: search_options.h

package info (click to toggle)
redisearch 1%3A1.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,076 kB
  • sloc: ansic: 79,131; python: 3,419; pascal: 1,644; makefile: 431; yacc: 422; sh: 5
file content (142 lines) | stat: -rw-r--r-- 3,581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef RS_QUERY_OPTIONS_H_
#define RS_QUERY_OPTIONS_H_

#include <stopwords.h>
#include <redisearch.h>
#include <sortable.h>
#include "config.h"

typedef enum {
  // No summaries
  SummarizeMode_None = 0x00,
  SummarizeMode_Highlight = 0x01,
  SummarizeMode_Synopsis = 0x02
} SummarizeMode;

#define SUMMARIZE_MODE_DEFAULT SummarizeMode_Synopsis
#define SUMMARIZE_FRAGSIZE_DEFAULT 20
#define SUMMARIZE_FRAGCOUNT_DEFAULT 3
#define SUMMARIZE_DEFAULT_OPEN_TAG "<b>"
#define SUMMARIZE_DEFAULT_CLOSE_TAG "</b>"
#define SUMMARIZE_DEFAULT_SEPARATOR "... "

typedef struct {
  uint32_t contextLen;
  uint16_t numFrags;
  char *separator;
} SummarizeSettings;

typedef struct {
  char *openTag;
  char *closeTag;
} HighlightSettings;

typedef struct {
  char *name;
  SummarizeSettings summarizeSettings;
  HighlightSettings highlightSettings;
  SummarizeMode mode;
  // Whether this field was explicitly requested by `RETURN`
  int explicitReturn;
} ReturnedField;

typedef struct {
  ReturnedField defaultField;

  // List of individual field specifications
  ReturnedField *fields;
  size_t numFields;
  uint16_t wantSummaries;
  // Whether this list contains fields explicitly selected by `RETURN`
  uint16_t explicitReturn;
} FieldList;

ReturnedField *FieldList_GetCreateField(FieldList *fields, RedisModuleString *rname);
void FieldList_Free(FieldList *fields);

typedef enum {
  Search_NoContent = 0x01,
  Search_Verbatim = 0x02,
  Search_NoStopwrods = 0x04,

  Search_WithScores = 0x08,
  Search_WithPayloads = 0x10,

  Search_InOrder = 0x20,

  Search_WithSortKeys = 0x40,
  Search_AggregationQuery = 0x80,
  Search_IsCursor = 0x100
} RSSearchFlags;

#define RS_DEFAULT_QUERY_FLAGS 0x00

// maximum results you can get in one query
#define SEARCH_REQUEST_RESULTS_MAX 1000000

typedef struct {
  /* The index name - since we need to open the spec in a side thread */
  char *indexName;

  // Stopword list
  StopWordList *stopwords;

  // Query language
  const char *language;

  // Pointer to payload info. The target resides in the search request itself
  RSPayload *payload;

  // Global field mask from INFIELDS
  t_fieldMask fieldMask;

  // Global flags
  RSSearchFlags flags;

  // Slop control
  int slop;

  int concurrentMode;

  RSSortingKey *sortBy;

  /* Paging */
  size_t offset;
  size_t num;

  /* Cursor read limit */
  size_t chunksize;

  char *expander;

  char *scorer;

  /* Does any stage in the query plan beyond the fiters nees the index results? Only scoring
   * functions need them, so for aggregate queries it makes our lives simpler to not assign it */
  int needIndexResult;
  long long timeoutMS;
  RSTimeoutPolicy timeoutPolicy;
  FieldList fields;
} RSSearchOptions;

#define RS_DEFAULT_SEARCHOPTS                 \
  ((RSSearchOptions){                         \
      .stopwords = NULL,                      \
      .language = NULL,                       \
      .payload = NULL,                        \
      .fieldMask = RS_FIELDMASK_ALL,          \
      .flags = RS_DEFAULT_QUERY_FLAGS,        \
      .slop = -1,                             \
      .concurrentMode = 1,                    \
      .sortBy = NULL,                         \
      .offset = 0,                            \
      .num = 10,                              \
      .expander = NULL,                       \
      .scorer = NULL,                         \
      .needIndexResult = 0,                   \
      .timeoutMS = 0,                         \
      .timeoutPolicy = TimeoutPolicy_Default, \
      .fields = (FieldList){},                \
  })

#endif