Hi Antonio,

[I'm ccing the answer to the cps-devel list as it might interest other
people]

Antonio Weber wrote:
> I'm from Germany and working for a good friend of me. He's using zope as
> CMS since 2 years. Atm we have at different servers different databases
> (ZODB, mysql etc) running with it.
> Now we want to index all objects stored in the databases at a central
> place. In my opinion nxlucene would fit perfect so in got the actual snv
> source and installed nxlucene. 

Great :)

> With the nuxeo.lucene package i wrote the
> testscript (test.py)
> When i run the script the server shut down without a message after
> sending the first search statement
> cat.searchResults(search_fields={u'uid': '1'})[0])
> Is this my fault or where can the error be?

I just ran your script and it runs well on my box (see below) :

[EMAIL PROTECTED] contrib]$ python test.py
aufruf cat.getFieldNamesFor():
(u'name', u'givenName', u'phone', u'fullname')
call cat.clean()
cat clean done
len of cat: 0
index 1: True
len of cat: 0
len of cat: 1
({u'phone': u'0815', u'fullname': u'Maier Sepp', u'uid': u'1', u'name':
u'Maier'},)
({u'uid': u'1', u'name': u'Maier'},)
({u'phone': u'0815', u'uid': u'1'},)
aufruf cat.index(2, o2) (erwartet wird True): True
len von cat: 2
({u'phone': u'125', u'fullname': u'Beckenbauer Franz', u'uid': u'2',
u'name': u'Beckenbauer'},)
({u'uid': u'2', u'name': u'Beckenbauer'},)
({u'phone': u'125', u'uid': u'2'},)
True
len cat: 2
({u'uid': u'3', u'name': u'H\xf6nes'},)
({u'uid': u'3', u'name': u'H\xf6nes'},)
({u'uid': u'2', u'name': u'Beckenbauer'},)
({u'uid': u'1', u'name': u'Maier'},)

I guess it can be because of the PyLucene installation that can be
sensitive on some platforms...

First try the NXLucene tests you should not get any errors.

Below are the test runner results using the NXLucene trunk.

[EMAIL PROTECTED] NXLucene]$ ./test.py -v -s nxlucene
Running tests from src
Running tests at level 1
Running unit tests:
  Running:
...................................................................................................
  Ran 99 tests with 0 failures and 0 errors in 5.574 seconds.
[EMAIL PROTECTED] NXLucene]$

How did you install PyLucene ? Which version ? If from source try a
"make check" within the source directory and check if you don't have any
errors.

We saw this case on some production instances. If you provide me enough
information on your PyLucene installation including gcc version,
binaries / sources etc... I will be able to help you to fix it.

Cheers,

        J.

P.S : Can I include your test file as a contrib within the NXLucene
repository ?

> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-
> 
> import time
> 
> from nuxeo.lucene.catalog import LuceneCatalog
> from nuxeo.lucene.interfaces import ILuceneCatalog
> from nuxeo.lucene.testing import registerDirective
> 
> from zope.app.testing import ztapi
> 
> import zope.interface
> import zope.app.intid.interfaces
> 
> import transaction
> 
> 
> class ITest(zope.interface.Interface):
>     pass
> 
> class P(object):
>     zope.interface.implements(ITest)
>     
>     def __init__(self, name, givenName = '', phone = ''):
>         self.name = name
>         self.givenName = givenName
>         self.phone = phone
> 
>     def getFullName(self):
>         return self.name + ' ' + self.givenName
> 
> 
> cat = LuceneCatalog('http://localhost:9180')
> ztapi.provideUtility(ILuceneCatalog, cat)
> 
> registerDirective("""
>       <lucene:fields for="zope.interface.Interface">
>           <lucene:field name = "name" attribute = 'name'
>                         type = "Text" analyzer = "Standard"/>
>       </lucene:fields>
>       """)
> 
> registerDirective("""
>       <lucene:fields for="zope.interface.Interface">
>           <lucene:field name = "givenName" attribute = 'givenName'
>                         type = "UnStored" analyzer = "Standard"/>
>       </lucene:fields>
>       """)
> 
> registerDirective("""
>       <lucene:fields for="zope.interface.Interface">
>           <lucene:field name = "phone" attribute = 'phone'
>                         type = "UnIndexed" analyzer = "Standard"/>
>       </lucene:fields>
>       """)
> 
> 
> registerDirective("""
>       <lucene:fields for="zope.interface.Interface">
>           <lucene:field name = "fullname" attribute = 'getFullName'
>                         type = "Text" analyzer = "Standard"/>
>       </lucene:fields>
>       """)
> 
> registerDirective("""
>       <lucene:columns>
>           <lucene:column field_name="name"/>
>       </lucene:columns>
>       """)
> 
> registerDirective("""
>       <lucene:columns>
>           <lucene:column field_name="phone"/>
>       </lucene:columns>
>       """)
> 
> registerDirective("""
>       <lucene:columns>
>           <lucene:column field_name="fullName"/>
>       </lucene:columns>
>       """)
> 
> print "aufruf cat.getFieldNamesFor(): \n" + str(cat.getFieldNamesFor())
> 
> 
> o1 = P(u'Maier', u'Sepp', u'0815')
> o2 = P(u'Beckenbauer', u'Franz', u'125')
> o3 = P(u'Hönes', 'Uli', u'089')
> 
> class Ids:
>     zope.interface.implements(zope.app.intid.interfaces.IIntIds)
>     
>     def __init__(self, data):
>         self.data = data
>     def getObject(self, id):
>         return self.data[id]
>     def __iter__(self):
>         return self.data.iterkeys()
> 
> ids = Ids({1: o1, 2: o2, 3: o3})
> ztapi.provideUtility(zope.app.intid.interfaces.IIntIds, ids)
> 
> print "call cat.clean()"
> cat.clean()
> print "cat clean done"
> transaction.commit()
> 
> print "len of cat: " + str(len(cat))
> 
> print "index 1: " + str(cat.index(1, o1))
> transaction.commit()
> print "len of cat: " + str(len(cat))
> while(len(cat) == 0): pass
> print "len of cat: " + str(len(cat))
> #print "waiting 4 sec"
> #time.sleep(4)
> 
> print str(cat.searchResults(search_fields={u'uid': '1'})[0])
> print str(cat.searchResults(return_fields=(u'name',), search_fields={u'uid': 
> '1'})[0])
> print str(cat.searchResults(return_fields=(u'phone',), search_fields={u'uid': 
> '1'})[0])
> 
> print "aufruf cat.index(2, o2) (erwartet wird True): " + str(cat.index(2, o2))
> transaction.commit()
> print "len von cat: " + str(len(cat))
> print str(cat.searchResults(search_fields={u'uid': '2'})[0])
> print str(cat.searchResults(return_fields=(u'name',), search_fields={u'uid': 
> '2'})[0])
> print str(cat.searchResults(return_fields=(u'phone',), search_fields={u'uid': 
> '2'})[0])
> 
> print str(cat.index(3, o3, indexes=('name',)))
> transaction.commit()
> print "len cat: " + str(len(cat))
> print str(cat.searchResults(search_fields={u'uid': '3'})[0])
> 
> print str(cat.searchResults(return_fields=(u'name',), search_fields={u'uid': 
> '3'})[0])
> print str(cat.searchResults(return_fields=(u'name',), search_fields={u'uid': 
> '2'})[0])
> print str(cat.searchResults(return_fields=(u'name',), search_fields={u'uid': 
> '1'})[0])
> 


-- 
Julien Anguenot | Nuxeo R&D (Paris, France)
Open Source ECM - www.nuxeo.com
CPS Platform - http://www.cps-project.org
Mobile: +33 (0) 6 72 57 57 66

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to