def run1(searcher, analyzer,target,distance,comein): print '&&&&&&&&&&&&&&&&&&&&&&&&&&' print target print [comein[1]] flit = kind_fliter.kind_fliter(comein[1].decode('utf8')) if (not flit[0]): segment = jieba.cut(flit[1]) command = " ".join(segment).replace("\n","").decode('utf-8') #print "Searching for:", command query_s = QueryParser(Version.LUCENE_CURRENT, "search", analyzer).parse(command) else: query_s = QueryParser(Version.LUCENE_CURRENT, "kind", analyzer).parse(flit[1]) #scoreDocs = searcher.search(query_s, 50).scoreDocs #print target cal_tar_x = int(target[0]*100000) cal_tar_y = int(target[1]*100000) #print cal_tar_x radius = distance*A*100000 #print radius cal_radius = int(radius) query1 = NumericRangeQuery.newFloatRange("calx",cal_tar_x-cal_radius,cal_tar_x+cal_radius,True,True) query2 = NumericRangeQuery.newFloatRange("caly",cal_tar_y-cal_radius,cal_tar_y+cal_radius,True,True) query = BooleanQuery() query.add(query1, BooleanClause.Occur.MUST) query.add(query2, BooleanClause.Occur.MUST) query.add(query_s, BooleanClause.Occur.MUST) scoreDocs = searcher.search(query, 500).scoreDocs return scoreDocs,query
def run2(searcher, analyzer,target,distance,comein): print [comein[1]] flit = kind_fliter.kind_fliter(comein[1]) #print flit[1].decode('utf8') query_s = [] if (not flit[0]): #print 11111111111 segment = jieba.cut(flit[1]) command = " ".join(segment).replace("\n","") #print "Searching for:", command query_s = QueryParser(Version.LUCENE_CURRENT, "search", analyzer).parse(command) else: query_s = QueryParser(Version.LUCENE_CURRENT, "kind", analyzer).parse(flit[1]) query = BooleanQuery() query.add(query_s, BooleanClause.Occur.MUST) scoreDocs = searcher.search(query, 500).scoreDocs return scoreDocs,query