MCPcopy Create free account
hub / github.com/alephdata/aleph / __init__

Method __init__

aleph/search/parser.py:124–155  ·  view source on GitHub ↗
(self, args, authz, limit=None)

Source from the content-addressed store, hash-verified

122 SMALL_FACETS = ("schema", "schemata", "collection_id", "countries", "languages")
123
124 def __init__(self, args, authz, limit=None):
125 super(SearchQueryParser, self).__init__(args, authz, limit=limit)
126 self.offset = min(MAX_PAGE, self.offset)
127 if (self.limit + self.offset) > MAX_PAGE:
128 self.limit = max(0, MAX_PAGE - self.offset)
129
130 # Set of field names to facet by (i.e. include the count of distinct
131 # values in the result set). These must match 'keyword' fields in the
132 # index.
133 self.facet_names = set(self.getlist("facet"))
134
135 # Query to use for highlighting, defaults to the search query
136 self.highlight_text = self.get("highlight_text", self.text)
137 # Include highlighted fragments of matching text in the result.
138 self.highlight = self.getbool("highlight", False)
139 self.highlight = self.highlight and SETTINGS.RESULT_HIGHLIGHT
140 self.highlight = self.highlight and self.highlight_text
141 # Length of each snippet in characters
142 self.highlight_length = self.getint("highlight_length", 120)
143 # Number of snippets per document, 0 = return full document text.
144 self.highlight_count = self.getint("highlight_count", 3)
145 # By default, the maximum number of characters analyzed for a highlight
146 # request is bounded by the value defined in the
147 # index.highlight.max_analyzed_offset setting (1000000 by default),
148 # and when the number of characters exceeds this limit an error is
149 # returned. By setting `max_analyzed_offset` to a non-negative value
150 # lower than `index.highlight.max_analyzed_offset`, the highlighting
151 # stops at this defined maximum limit, and the rest of the text is not
152 # processed, thus not highlighted and no error is returned.
153 self.max_highlight_analyzed_offset = self.getint(
154 "max_highlight_analyzed_offset", 999999
155 )
156
157 def get_facet_size(self, name):
158 """Number of distinct values to be included (i.e. top N)."""

Callers

nothing calls this directly

Calls 5

getlistMethod · 0.80
getboolMethod · 0.80
getintMethod · 0.80
__init__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected