Details
Description
FTS search query in Python 3.x does NOT return fields anymore.
FTS search query in Python 2.x DOES.
Explanations:
In 2.x I have the following code :
from couchbase.cluster import Cluster, PasswordAuthenticator |
from couchbase.fulltext import Params, MatchQuery, PrefixQuery |
import time |
from couchbase.bucket import Bucket |
cluster = Cluster('couchbase://localhost:8091') |
cluster.authenticate(PasswordAuthenticator('Administrator', 'password')) |
a
|
# open travel-sample bucket
|
cb = cluster.open_bucket('demo2') |
start = time.time() |
it = cb.search('demo2_nGram', PrefixQuery('pari'), fields = ["name"], limit=20) |
a=[] |
for hit in it: |
print(hit) |
print('Time taken: ', time.time() - start, " seconds") |
The field name is actually returned. Result is OK.
On 3.X (I tested 3.0.1 and 3.0.5, the latest one), corresponding code is:
from couchbase.cluster import Cluster, ClusterOptions, PasswordAuthenticator |
from couchbase.exceptions import CouchbaseException |
from couchbase.search import QueryStringQuery, SearchQuery, MatchQuery, SearchOptions, PrefixQuery, HighlightStyle, SortField, SortScore, TermFacet |
import time |
cluster = Cluster('couchbase://localhost:8091', ClusterOptions(PasswordAuthenticator('Administrator', 'password'))) |
start = time.time() |
result = cluster.search_query('demo2_nGram', PrefixQuery('pari'), fields=['name'], limit=20) |
a=[] |
for row in result.rows(): |
print(len(row.fields)) |
#print(row.score) |
a.append(row.id) |
print('Time taken: ', time.time() - start, " seconds") |
print(len(result.rows())) |
|
And no fields is returned : len(row.fields) === 0
I checked in wireshark and I CAN see the fields result in the response returned to the client BUT there is nothing in my row.fields object (empty). Result is NOK.
Note : I “stored” the fields name and cityname (this one is not used here) in the FTS index definition (see picture in attachment)
Attachments
Issue Links
- relates to
-
PYCBC-1060 FTS - Facet result missing fields
-
- Resolved
-
For Gerrit Dashboard: PYCBC-1032 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
149112,3 | PYCBC-1032 - Add fields in FTS result | master | couchbase-python-client | Status: MERGED | +2 | +1 |