Exemplo n.º 1
0
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 testExclusive(self):

        searcher = IndexSearcher(self.directory, True)
        # pub date of TTC was October 1988
        query = NumericRangeQuery.newIntRange("pubmonth",
                                              198805,
                                              198810,
                                              False, False)
        topDocs = searcher.search(query, 100)
        self.assertEqual(0, topDocs.totalHits)
        searcher.close()
    def testExclusive(self):

        searcher = self.getSearcher()
        # pub date of TTC was October 1988
        query = NumericRangeQuery.newIntRange("pubmonth",
                                              Integer(198805),
                                              Integer(198810),
                                              False, False)
        topDocs = searcher.search(query, 100)
        self.assertEqual(0, topDocs.totalHits)
        del searcher
Exemplo n.º 4
0
    def testExclusive(self):

        searcher = IndexSearcher(self.directory, True)
        # pub date of TTC was October 1988
        query = NumericRangeQuery.newIntRange("pubmonth",
                                              Integer(198805),
                                              Integer(198810),
                                              False, False)
        topDocs = searcher.search(query, 100)
        self.assertEqual(0, topDocs.totalHits)
        searcher.close()
Exemplo n.º 5
0
def run3(searcher, analyzer,target,distance,comein):
        #print '&&&&&&&&&&&&&&&&&&&&&&&&&&'
        #print target
        print [comein[1]]
        distance = 5000
        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
Exemplo n.º 6
0
    def testAnd(self):

        searchingBooks = TermQuery(Term("subject", "search"))
        books2004 = NumericRangeQuery.newIntRange("pubmonth", Integer(200401), Integer(200412), True, True)

        searchingBooks2004 = BooleanQuery()
        searchingBooks2004.add(searchingBooks, BooleanClause.Occur.MUST)
        searchingBooks2004.add(books2004, BooleanClause.Occur.MUST)

        searcher = self.getSearcher()
        scoreDocs = searcher.search(searchingBooks2004, 50).scoreDocs

        self.assertHitsIncludeTitle(searcher, scoreDocs, "Lucene in Action")
Exemplo n.º 7
0
    def testAnd(self):

        searchingBooks = TermQuery(Term("subject", "search"))
        books2004 = NumericRangeQuery.newIntRange("pubmonth", Integer(200401),
                                                  Integer(200412), True, True)

        searchingBooks2004 = BooleanQuery()
        searchingBooks2004.add(searchingBooks, BooleanClause.Occur.MUST)
        searchingBooks2004.add(books2004, BooleanClause.Occur.MUST)

        searcher = IndexSearcher(self.directory, True)
        scoreDocs = searcher.search(searchingBooks2004, 50).scoreDocs

        self.assertHitsIncludeTitle(searcher, scoreDocs, "Lucene in Action")