Riak Search Issue

tele tele at rhizomatica.org
Tue Aug 19 01:45:52 EDT 2014


Hi,

I had the same issue while playing with the latest python client and
riak search 2.0 but i checked the code and sorted it out.
In the new documentation fulltext_search() is not mentioned, it uses
search()
http://basho.github.io/riak-python-client/query.html#fulltext-search

If you dig in the code basically search() calls fulltext_search()

    def search(self, query, **params):
        """
        Queries a search index over objects in this bucket/index. See
        :meth:`RiakClient.fulltext_search()
        <riak.client.RiakClient.fulltext_search>` for more details.
        """
        return self._client.fulltext_search(self.name, query, **params)

As you can see the first arg of fulltext_search uses as index
self.name. In this case self.name is the name of the bucket because the
method is implemented on the Bucket object.

So if you add an index on the bucket that has a different name from the
bucket and you use search(), it will give you the error of index not
found. This is because the name of the index has to match with the name
of the bucket.

I believe it's worth to mention it in the documentation, so
people don't freak out when following instructions and getting an index
error from search() :)

Or maybe just add back the possibility of specifying the index on the
search(). Up to you

:tele



On Mon, 18 Aug 2014 23:38:51 +0200
Alex De la rosa <alex.rosa.box at gmail.com> wrote:

> Hi Eric,
> 
> Cool! This new syntax really worked :) even on different bucket
> names :) It has been driving me crazy all day... haha, glad is
> finally sorted out.
> 
> PYTHON:
> results = client.fulltext_search('famoso', 'name_s:Lio*')
> print results
> 
> OUTPUT:
> {'num_found': 2, 'max_score': 1.0, 'docs': [{u'age_i': u'30',
> u'name_s': u'Lionel', u'_yz_rk': u'lionel', u'_yz_rb': u'fcb',
> u'score': u'1.00000000000000000000e+00', u'leader_b': u'true',
> u'_yz_id': u'1*futbolistas*fcb*lionel*59', u'_yz_rt':
> u'futbolistas'}, {u'age_i': u'30', u'name_s': u'Lionel', u'_yz_rk':
> u'lionel', u'_yz_rb': u'famoso', u'score':
> u'1.00000000000000000000e+00', u'leader_b': u'true', u'_yz_id':
> u'1*futbolistas*famoso*lionel*8', u'_yz_rt': u'futbolistas'}]}
> 
> Thanks!
> Alex
> 
> 
> On Mon, Aug 18, 2014 at 11:33 PM, Eric Redmond <eredmond at basho.com>
> wrote:
> 
> > Alex,
> >
> > I was mistaken about the bucket search. The documentation is wrong,
> > and the API is weirded for backward compatibility reasons. You
> > should be able to search by index name this way.
> >
> > client.fulltext_search(index, query, **params)
> >
> > We'll update the docs to match.
> >
> > Eric
> >
> >
> > On Aug 18, 2014, at 2:29 PM, Alex De la rosa
> > <alex.rosa.box at gmail.com> wrote:
> >
> > Hi Sean,
> >
> > Yeah, I opted to follow that pattern on my latest attempt as I see
> > it more clear that the way in the documentation. Still same issue
> > although with Eric we saw it works fine when index and bucket has
> > the same name.
> >
> > Thanks!
> > Alex
> >
> >
> > On Mon, Aug 18, 2014 at 11:27 PM, Sean Cribbs <sean at basho.com>
> > wrote:
> >
> >> Don't use bucket with 2 arguments, use
> >> client.bucket_type('futbolistas').bucket('fcb'). This makes your
> >> intent more clear. The 2-arity version of bucket() was for
> >> backwards-compatibility.
> >
> >
> >
> >





More information about the riak-users mailing list