On 07/27/2011 05:09 AM, 许凌志(Jamesxu) wrote:
> On Tue, Jul 26, 2011 at 3:57 PM, Sergiu Dumitriu<[email protected]>  wrote:
>
>>
>>
>> On 07/25/2011 05:08 AM, 许凌志(Jamesxu) wrote:
>>> Hi All, how can I query the attachments of a specific page, for example
>>> "Main.testpage"
>>>
>>> I found if I use the query
>>> space:Main AND filename:__INPUT__* AND type:attachment
>>> I can get the attachments only from the Main space.
>>>
>>> but how about a specific page, I have tried
>>> page:Main.testpage AND filename:__INPUT__* AND type:attachment
>>> wikipage:Main.testpage AND filename:__INPUT__* AND type:attachment
>>> but no one can give the right results.
>>
>> To see which fields are indexed, you can look at the Java sources,
>> starting from
>>
>> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-lucene/src/main/java/com/xpn/xwiki/plugin/lucene/AttachmentData.java
>>
>> The document name is indexed both as "name", which holds just the name,
>> without the space, and "fullname", which contains the space as well --
>> Space.Document
>>
>
> I follow your suggestion, and test some queries, I list some query I have
> tested bellow with its function descriptions:
>
> Query 1:  space:Main AND filename:__INPUT__* AND type:attachment
> Description: search the attachments whose filename contains "__INPUT__" and
> it belong to the pages in the 'Main' space
> Query 2:  name:testpage AND filename:__INPUT__* AND type:attachment
> Description: search the attachments whose filename contains "__INPUT__" and
> it belong to the page 'testpage'

Q2 is a bit wrong. It will return attachments for all the documents 
named testpage, whatever their space. In practice, a link pointing to 
[[[email protected]]] will link only to documents in the current space.

For example, linking to [email protected] only works when you're in 
the Sandbox space, otherwise it will be a broken link. However, this 
query will always return this attachment when searching in any WebHome 
document.

Q3 is better.

> Query 3:  space:Main AND name:testpage AND filename:__INPUT__* AND
> type:attachment
> Description: search the attachments whose filename contains "__INPUT__" and
> it belong to the page testpage in the 'Main' space

An alternative is:

fullname:Main.testpage AND filename:__INPUT__* AND type:attachment

> Query 4: space:Main AND  name:__INPUT__* AND type:wikipage
> Description: search the wiki pages whose name contains "__INPUT__" and it
> belong to the 'Main' space

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to