Hi, I'm trying to index some user information and then search it. I want to be able to search for instance a username, with the equivalent of searching with LIKE '%name%' in a SQL language. I've created the following index file: userid : boolean=Q unique=Q field=userid username : index=XU index field=username name : index=XN index field=name city : index=XC index field=city province : boolean=XPR gender : boolean=XG avatar : boolean=XP birthday : boolean=D birthmonth : boolean=M birthyear : boolean=Y birthdate : value=1 question : index=XQ weight=3 index field=question text : unhtml index style : boolean=XS And I filled the database with this data. Now, I want to search for users whose name is something like 'maarten', but can be 'maarten123' or 'smaarten3' aswell. I'm not sure how to do this. I have specified fields, but I'm unsure how to use these. Can anyone explain how to search within specific fields? Thanks, Maarten
M.J. van der Veen
2006-Dec-23 14:40 UTC
[Xapian-discuss] Re: Searching in different fields
Oh, I guess I have to mention that I'm using XAPIAN 0.9.7 and OMEGA 0.9.7. On 12/23/06, M.J. van der Veen <forward@mvanderveen.nl> wrote:> Hi, > > I'm trying to index some user information and then search it. I want > to be able to search for instance a username, with the equivalent of > searching with LIKE '%name%' in a SQL language. > > I've created the following index file: > userid : boolean=Q unique=Q field=userid > username : index=XU index field=username > name : index=XN index field=name > city : index=XC index field=city > province : boolean=XPR > gender : boolean=XG > avatar : boolean=XP > birthday : boolean=D > birthmonth : boolean=M > birthyear : boolean=Y > birthdate : value=1 > question : index=XQ weight=3 index field=question > text : unhtml index > style : boolean=XS > > > And I filled the database with this data. > > Now, I want to search for users whose name is something like > 'maarten', but can be 'maarten123' or 'smaarten3' aswell. > > I'm not sure how to do this. I have specified fields, but I'm unsure > how to use these. Can anyone explain how to search within specific > fields? > > Thanks, > > Maarten >
I'm afraid you are partially out of luck. The Xapian query parser has a wildcard (http://xapian.org/docs/queryparser.html) but it's only for trailing values. You could search for maarten* and get maarten123, but there doesn't appear to be a way to get smaarten. Jim. M.J. van der Veen wrote:> Hi, > > I'm trying to index some user information and then search it. I want > to be able to search for instance a username, with the equivalent of > searching with LIKE '%name%' in a SQL language. > > I've created the following index file: > userid : boolean=Q unique=Q field=userid > username : index=XU index field=username > name : index=XN index field=name > city : index=XC index field=city > province : boolean=XPR > gender : boolean=XG > avatar : boolean=XP > birthday : boolean=D > birthmonth : boolean=M > birthyear : boolean=Y > birthdate : value=1 > question : index=XQ weight=3 index field=question > text : unhtml index > style : boolean=XS > > > And I filled the database with this data. > > Now, I want to search for users whose name is something like > 'maarten', but can be 'maarten123' or 'smaarten3' aswell. > > I'm not sure how to do this. I have specified fields, but I'm unsure > how to use these. Can anyone explain how to search within specific > fields? > > Thanks, > > Maarten > > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss@lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss >