284 cond.set_skip(skip) |
284 cond.set_skip(skip) |
285 |
285 |
286 # execute |
286 # execute |
287 return self.search_cond(cond) |
287 return self.search_cond(cond) |
288 |
288 |
289 def search_simple (self, channel, query, count=None, offset=None, search_msg=True, search_nick=False) : |
289 def search_simple (self, channel, query, count=None, offset=None) : |
290 """ |
290 """ |
291 Search for lines from the given channel for the given simple query. |
291 Search for lines from the given channel for the given simple query. |
292 |
292 |
293 The search_* params define which attributes to search for (using fulltext search for the message, STROR for |
293 The given text is searched for in the text of the given channel's entries, and the list of results in |
294 attributes). |
294 reverse time order is returned. |
295 """ |
295 """ |
296 |
296 |
297 # search attributes |
297 # search attributes |
298 attrs = [] |
298 attrs = [] |
299 |
299 |
300 # nickname target query |
|
301 if search_nick : |
|
302 attrs.append("source_nickname STRINC %s" % query) |
|
303 # attrs.append("target_nickname STRINC %s" % query) |
|
304 |
|
305 # use search(), backwards |
300 # use search(), backwards |
306 results = list(self.search( |
301 results = list(self.search( |
307 # simplified phrase |
302 # simplified phrase |
308 options = hype.Condition.SIMPLE, |
303 options = hype.Condition.SIMPLE, |
309 |
304 |
310 # specific channel |
305 # specific channel |
311 channel = channel, |
306 channel = channel, |
312 |
307 |
313 # given phrase |
308 # given phrase |
314 phrase = query if search_msg else None, |
309 phrase = query, |
315 |
310 |
316 # attributes defined above |
311 # attributes defined above |
317 attrs = attrs, |
312 attrs = attrs, |
318 |
313 |
319 # order by timestamp, descending (backwards) |
314 # order by timestamp, descending (backwards) |
325 )) |
320 )) |
326 |
321 |
327 # reverse |
322 # reverse |
328 return reversed(results) |
323 return reversed(results) |
329 |
324 |
|
325 def search_advanced (self, channel, phrase=None, nick_query=None, count=None, offset=None) : |
|
326 """ |
|
327 Search for lines from the given channel for the given full-featured query. |
|
328 |
|
329 The given phrase is used to build the condition, or alternatively, the given extra *_query parameters can |
|
330 be used to specific additional attributes to search. |
|
331 """ |
|
332 |
|
333 attrs = [] |
|
334 |
|
335 if nick_query : |
|
336 # search for messages from specific nickname |
|
337 attrs.append("source_nickname STRINC %s" % nick_query) |
|
338 |
|
339 # use search(), backwards |
|
340 results = list(self.search( |
|
341 # specific channel |
|
342 channel = channel, |
|
343 |
|
344 # given phrase |
|
345 phrase = phrase, |
|
346 |
|
347 # attributes defined above |
|
348 attrs = attrs, |
|
349 |
|
350 # order by timestamp, descending (backwards) |
|
351 order = "timestamp NUMD", |
|
352 |
|
353 # count/offset |
|
354 max = count, |
|
355 skip = offset, |
|
356 )) |
|
357 |
|
358 # reverse |
|
359 return reversed(results) |
|
360 |
330 def list (self, channel, date, count=None, skip=None) : |
361 def list (self, channel, date, count=None, skip=None) : |
331 """ |
362 """ |
332 List all indexed log items for the given UTC date |
363 List all indexed log items for the given UTC date |
333 """ |
364 """ |
334 |
365 |