cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to search on name fragment

hsjawanda
Champ in-the-making
Champ in-the-making
Hi all,

I am constructing a lucene query to search for names (folder and content names – this is a field of type "cm:name").  I have a number of gifs that are named <stem>_ani.gif. The <stem> contains underscores.

If I search for "ani.gif*", I get the results I want. If I use any other search term ("*ani*", "*gif" or something from the <stem> part of the filename), I get nothing.

Here's the query that yields the desired results:

TEXT:"ani.gif*"
( @\{http\://www.alfresco.org/model/content/1.0\}name:'ani.gif*")
( @\{http\://www.alfresco.org/model/content/1.0\}description:'ani.gif*")

And here are queries that don't return anything:
Query 1:

TEXT:"ani*"
( @\{http\://www.alfresco.org/model/content/1.0\}name:'ani*")
( @\{http\://www.alfresco.org/model/content/1.0\}description:'ani*")


Query 2:

TEXT:"*ani*"
( @\{http\://www.alfresco.org/model/content/1.0\}name:'*ani*")
( @\{http\://www.alfresco.org/model/content/1.0\}description:'*ani*")


Query 3:

TEXT:"*gif*"
( @\{http\://www.alfresco.org/model/content/1.0\}name:'*gif*")
( @\{http\://www.alfresco.org/model/content/1.0\}description:'*gif*")

Also, there are some description fields that contain the word "desperate". I get results only if I search for the whole word – searching for "desp*" returns no results.

Can anybody help explain whats going on?  The searching behaviour doesn't seem to match the examples given in http://lucene.apache.org/java/docs/queryparsersyntax.html.

Looks like searching is tokenizing and can only return results when a whole token is matched.  If this is correct, what characters does Lucene (as used in Alfresco) tokenize on (especially, does it tokenize on underscores)?

How can I change the indexing and/or the search query to search for files (content) based on extensions?  For example, I want to get a list of all gifs when I search for "*.gif".

All help greatly appreciated.  Thanks.
4 REPLIES 4

kevinr
Star Contributor
Star Contributor
Hi,

I generate searches similar to these for the simple/advanced search in the UI and I don't have any problems.

E.g. if you have an item called "release.gif"
then a search:

@\{http\://www.alfresco.org/model/content/1.0\}name:release*
will find it ok, and also a search:

@\{http\://www.alfresco.org/model/content/1.0\}name:*elease*
will also find it ok.

I think the problem in your searches in the use of quotes around the terms when searching against an attribute. E.g. you search for:

TEXT:"*ani*"
( @\{http\://www.alfresco.org/model/content/1.0\}name:'*ani*")
whereas if you change it to this:

TEXT:*ani*
( @\{http\://www.alfresco.org/model/content/1.0\}name:*ani*)
You should get the results you are looking for.

Hope this helps,

Kevin

rsfeir
Champ in-the-making
Champ in-the-making
Sweet, this solved my other problem where I was getting an npe and it wasn't finding my file!  cool!

2 birds with one stone.

R

hsjawanda
Champ in-the-making
Champ in-the-making
Thanks Kevin, your tip fixed my problems :-)… it was stupid of me not to have seen that right away.

andy
Champ on-the-rise
Champ on-the-rise
Hi

To be explicit….

Using "" in a search like ns\:woof:"*and*"
Does a lucene phrase search - * is not treated as a wild card in phrase searches - it will split this into tokens. The default result is do an exact match for the token "*and*" (not tokens that match this pattern) which probably does not exist

Wildcards are only available outside phrase searches, e.g.

ns\:woof:*and*

In phrase searches, the text is tokenised and '_' is used as a token separator. By default we use the StandardAnalyser for text.

Can you send me the null pointer exception and I will have a look at this??

Regards

Andy