[Grok-dev] Indexing problem

Lumír Jasiok lumir.jasiok at alfawolf.eu
Sun Oct 14 09:18:04 UTC 2012


Hi,

I am trying to create full text search in Grok. I have created search using multiple indexes, but I have trouble with search on top of indexes.

Lets say that I have two fields I want to search: first_name and last_name.

In my Person object (grok.Model), I have searchableText method which return self.first_name + self.last_name.

class Person(grok.Model):
	grok.implements(IPerson, IMetadata, ISearchable)
	first_name = u''
	last_name = u''

	def searchableText(self):
		return self.first_name+self.last_name

class PersonIndexes(grok.Indexes):
	grok.context(ISearchable)
	first_name = grok.index.Text()
	last_name = grok.index.Text()

class IPerson(interface.Interface):
	first_name = schema.TextLine(title=u'First name', required=True)
	last_name = schema.TextLine(title=u'Last name', required=True)

class ISearchable(interface.Interface)
	first_name = interface.Attribute('first_name')
	last_name = interface.Attribute('last_name')
	def searchableText():
	
On the View side I have PersonSearch(grok.View) object with update method, which includes query.
	if query:
		catalog = getUtility(ICatalog)
		query = "*%s*" % (query,)
		self.results = catalog.searchResults(searchableText=query)

I have created Person object with FirstName and LastName.

In case of query that starts with string FirstN, I am able to get correct value from index, it returns me Person object I want. But in case, that query begins with LastN, I din't get anything. What I am doing wrong?

Second problem I have is, that I don't know how can I access catalog admin UI. 

ULR: http://localhost:8080/test/++etc++site/Catalog/@@advanced.html is not working. What is correct Catalog URL?

Thanks for any help.

Best Regards

Lumír Jasiok

--

Lumír Jasiok 
AlfaWolf s.r.o. 
Czech Republic
E-mail: lumir.jasiok at alfawolf.eu
http://www.alfawolf.eu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20121014/ac4c9647/attachment.html>


More information about the Grok-dev mailing list