示例#1
0
    def test_build_object_urlpart2(self):
        obj_a = Argument('')
        obj_b = Argument('gorilla')
        with self.assertRaises(ValueError) as context:
            build_object_urlpart(obj_a, obj_b)

        self.assertTrue('Please enter both objects!' in str(context.exception))
示例#2
0
def request_es_ML(fast_search, obj_a, obj_b):
    url = build_object_urlpart(obj_a, obj_b)

    size = 10000
    if fast_search == 'true':
        size = 500
    url += get_query_range(size)
    return send_request(url)
示例#3
0
 def test_build_object_urlpart1(self):
     obj_a = Argument('ape')
     obj_b = Argument('gorilla')
     url = build_object_urlpart(obj_a, obj_b)
     self.assertTrue(
         url ==
         'http://ltdemos.informatik.uni-hamburg.de/depcc-index/depcc/_search?q=text:"ape"%20AND%20"gorilla"'
         or url ==
         'http://ltdemos.informatik.uni-hamburg.de/depcc-index/commoncrawl2/_search?q=text:"ape"%20AND%20"gorilla"'
     )
示例#4
0
def request_es_triple(obj_a, obj_b, aspects):
    url = build_object_urlpart(obj_a, obj_b)
    url += '%20AND%20('
    first = True
    for aspect in aspects:
        if first:
            url += '\"{}\"'.format(aspect.name)
        else:
            url += '%20OR%20\"{}\"'.format(aspect.name)
    url += ')' + get_query_range(10000)
    return send_request(url)
示例#5
0
def request_es(fast_search, obj_a, obj_b):
    '''
    Sends a request to Elastic Search and returns the result as a JSON object.

    obj_a:   String
            an object to be searched via Elastic Search

    obj_b:   String
            another object to be searched via Elastic Search
    '''
    url = build_object_urlpart(obj_a, obj_b)
    url = add_marker_urlpart(url, fast_search)
    return send_request(url)