240 # set options |
240 # set options |
241 cond.set_options(options) |
241 cond.set_options(options) |
242 |
242 |
243 if channel : |
243 if channel : |
244 # add channel attribute |
244 # add channel attribute |
245 cond.add_attr("channel STREQ %s" % (channel.id, )) |
245 cond.add_attr(("channel STREQ %s" % channel.id).encode('utf8')) |
246 |
246 |
247 if attrs : |
247 if attrs : |
248 # add attributes |
248 # add attributes |
249 for attr in attrs : |
249 for attr in attrs : |
250 cond.add_attr(attr) |
250 cond.add_attr(attr.encode('utf8')) |
251 |
251 |
252 if phrase : |
252 if phrase : |
253 # add phrase |
253 # add phrase |
254 cond.set_phrase(phrase) |
254 cond.set_phrase(phrase.encode('utf8')) |
255 |
255 |
256 if order : |
256 if order : |
257 # set order |
257 # set order |
258 cond.set_order(order) |
258 cond.set_order(order) |
259 |
259 |
266 cond.set_skip(skip) |
266 cond.set_skip(skip) |
267 |
267 |
268 # execute |
268 # execute |
269 return self.search_cond(cond) |
269 return self.search_cond(cond) |
270 |
270 |
271 def search_simple (self, channel, query, count=None, offset=None) : |
271 def search_simple (self, channel, query, count=None, offset=None, search_msg=True, search_nick=False) : |
272 """ |
272 """ |
273 Search for lines from the given channel for the given simple query |
273 Search for lines from the given channel for the given simple query. |
274 """ |
274 |
|
275 The search_* params define which attributes to search for (using fulltext search for the message, STROR for |
|
276 attributes). |
|
277 """ |
|
278 |
|
279 # search attributes |
|
280 attrs = [] |
|
281 |
|
282 # nickname target query |
|
283 if search_nick : |
|
284 attrs.append("source_nickname STRINC %s" % query) |
|
285 # attrs.append("target_nickname STRINC %s" % query) |
275 |
286 |
276 # use search(), backwards |
287 # use search(), backwards |
277 results = list(self.search( |
288 results = list(self.search( |
278 # simplified phrase |
289 # simplified phrase |
279 options = hype.Condition.SIMPLE, |
290 options = hype.Condition.SIMPLE, |
280 |
291 |
281 # specific channel |
292 # specific channel |
282 channel = channel, |
293 channel = channel, |
283 |
294 |
284 # given phrase |
295 # given phrase |
285 phrase = query, |
296 phrase = query if search_msg else None, |
|
297 |
|
298 # attributes defined above |
|
299 attrs = attrs, |
286 |
300 |
287 # order by timestamp, descending (backwards) |
301 # order by timestamp, descending (backwards) |
288 order = "timestamp NUMD", |
302 order = "timestamp NUMD", |
289 |
303 |
290 # count/offset |
304 # count/offset |