On 10/04/2011 06:04 AM, Legeinfo wrote:
Lucene:
I try to find all jpg´s with "foo" in the page content. I only get the jpg
or the content of a page.
(jpg AND type:attachment) AND (foo) not working
(jpg AND type:attachment) AND (Content:foo) not working
(jpg AND type:attachment) AND (foo and object:XWiki.XWikiContent) not
working
Suggestions?
That can't work. Lucene matches the whole query against a "document",
where document refers to an entry in the Lucene index, not an XWiki
Document.
Now, each attachment is indexed in its own Lucene document, and the
content of the owner XWikiDocument of that attachment isn't included in
the indexed text.
Another problem is that the filename isn't split on dots, so jpg won't
match. Lucene doesn't support wildcards at the start of a search term,
so you can't search for *.jpg either.
So, your only choice is to patch the Lucene plugin to either:
- include the list of attachments in the LDocument corresponding to an
XDocument, but this means that the search will return not the
attachment, but the owner document
- include the owner XDocument content in a field of the LDocument
corresponding to the attachment, and also index the MIME type of the
attachment in a field so that you can search for:
type:attachment AND mime:"image/jpg" AND doccontent:"foo"
--
Sergiu Dumitriu
http://purl.org/net/sergiu/