def search(): search_term = request.args.get('q') print 'User searched for', search_term keys = [] # Lab 5: Use the English FTS index to search with the term provided result = bucket.search('English', FT.MatchQuery(search_term, fuzziness=1)) for row in result: keys.append(row['id']) print 'Found matches', ', '.join(keys) return jsonify({'keys': keys})
def test_match_query(self): exp_json = { 'query': { 'match': 'salty beers', 'analyzer': 'analyzer', 'boost': 1.5, 'field': 'field', 'fuzziness': 1234, 'prefix_length': 4 }, 'size': 10, 'indexName': 'ix' } q = cbft.MatchQuery('salty beers', boost=1.5, analyzer='analyzer', field='field', fuzziness=1234, prefix_length=4) p = cbft.Params(limit=10) self.assertEqual(exp_json, cbft.make_search_body('ix', q, p))
#!/usr/bin/env python from __future__ import print_function from pprint import pprint from couchbase.bucket import Bucket import couchbase.fulltext as FT cb = Bucket() results = cb.search('travel-search', FT.MatchQuery('part', fuzziness=0, field='content'), limit=3, facets={'countries': FT.TermFacet('country', limit=3)}) for row in results: pprint(row) print('Facet results:')