Hi James,

That's just a query problem. The queries that are used for the search
suggest are located in XWiki.SearchSuggestConfig. The query for Document
Name/Content are not complete. They also need to specify that the result
should be a document, and not anything (like attachments for instance). The
correct query for searching for documents by document name should be:

name:__INPUT__* AND type:wikipage

For attachment name, the correct query should be:

filename:__INPUT__* AND type:attachment

So, for your usecase (quering documents by name or attachments by name), the
query should be:

(filename:__INPUT__* AND type:attachment) OR (name:__INPUT__* AND
type:wikipage)

I`ve tested it out by creating a page named "IconTest" and then searching
for "icon". The results were:

<results>
<rs id="/xwiki/bin/download/XWiki/RequestsStatus/icon.png"
info="XWiki.RequestsStatus">icon.png</rs>
<rs id="/xwiki/bin/download/XWiki/ExtensionManager/icon.png"
info="XWiki.ExtensionManager">icon.png</rs>
<rs id="/xwiki/bin/download/Panels/PanelWizard/icon.png"
info="Panels.PanelWizard">icon.png</rs>
<rs id="/xwiki/bin/download/XWiki/OfficeImporterAdmin/icon.png"
info="XWiki.OfficeImporterAdmin">icon.png</rs>
<rs id="/xwiki/bin/download/XWiki/SearchAdmin/icon.png"
info="XWiki.SearchAdmin">icon.png</rs>
<rs id="/xwiki/bin/download/Blog/Categories/icon.png"
info="Blog.Categories">icon.png</rs>            <----------- attachments
<rs id="/xwiki/bin/view/Main/IconTest"
info="Main.IconTest">IconTest</rs>              <----------- documents
</results>

Ignore the fact that the result is in XML, you can make it json, as
suggested in my previous mail.

Hope that works for you.

Thanks,
Eduard

2011/7/20 许凌志(Jamesxu) <[email protected]>

> Thanks Eduard very much, It is really helpful, today I am trying to use
> SuggestLuceneService to test the autosuggestion functions, I found a
> problem.
>
> For example, I create a page named "jamesxu", and upload an attachment
> named
> "autosuggest1.js", then I input the query "jame" to the search box on the
> top right of the page, the suggestion list shows up, but the results in the
> "Document Name" and "Document Content" contains both the wiki page
> "jamesxu"
> and its attachment "autosuggest1.js", this behaviour is not excepted in the
> autosuggestion features of the editor, because when user types "jame“, he
> really wants to query the wiki page or attachment begin with  or contains
> "jame",  the attachment "autosuggest1.js" does not contains "jame", it
> should not be included in the suggestion results.
>
> On Tue, Jul 19, 2011 at 10:14 PM, Eduard Moraru <[email protected]
> >wrote:
>
> > Hi James,
> >
> > I agree with Marius that you should reuse as much as possible what
> already
> > exists instead of creating an alternate service that does, in a great
> > proportions, the same as an existing one but has one extra feature.
> >
> > So, as I was browsing trough REST's resources, I noticed an undocumented
> > "/wikis/{wikiName}/attachments" [1] resource at the wiki level that is
> able
> > to search for attachments. As you can see from the method's signature, it
> > accepts parameters to filter your search by attachment name, page, space,
> > author, and type. I will fix the REST API documentation and include it.
> >
> > This resource should do the trick for what you need, used in conjunction
> > with the search resource that should handle documents.
> >
> > The advantage of this is that you can get json, as you did for the search
> > resource.
> > The disadvantage of the whole REST API, for your needs, might be that it
> is
> > limited at wiki level and can not perform a multi-wiki search in one
> query
> > (wihout you having to do a search for each wiki).
> >
> > On the other side, the Lucene search does not have this problem because
> it
> > indexes all the wikis and can perform searches on all wikis in one query
> > and
> > it does it much faster than REST (which uses database queries). Also,
> > lucene
> > is used in the search suggest (the one at the top-right corner of the
> > screen) and in the main XWiki search as well, so it would be much better
> if
> > the results were consistent. Besides this, if the lucene system is
> improved
> > over time, your results will also be improved as a result.
> >
> > So my suggestion is that you modify XWiki.SuggestLuceneService and make
> it
> > accept a "media" parameter (or something similar) that should accept at
> > least 2 values: "xml"(default) and "json". Based on this value, you can
> > wrap
> > the results of the lucene search into a basic json structure that you can
> > easily use in your suggest box. You can check [2][3] and [4] for
> references
> > of how to use Lucene search in XWiki.
> > Once you are done with it, you can even do a pull request so that this
> > feature gets integrated into XWiki.
> >
> > The best and cleanest solution would be that the REST search resource
> used
> > internally lucene instead of a custom database query and that there would
> > be
> > a single search back-end (preferably configurable in administration).
> > Anyway, it's not your job to fix XWiki :) so making
> > XWiki.SuggestLuceneService return json too is the best way to go right
> now,
> > IMO.
> >
> > Thanks,
> > Eduard
> >
> > -----------------
> > References:
> > [1]
> >
> >
> https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest/resources/wikis/WikiAttachmentsResource.java
> > [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin
> > [3]
> >
> >
> 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/LucenePluginApi.java
> > [4]
> >
> >
> 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/SearchResult.java
> >
> >
> > On Tue, Jul 19, 2011 at 8:36 AM, 许凌志(Jamesxu) <[email protected]
> > >wrote:
> >
> > > Hi, these days I need to implement the rest services for getting
> > suggestion
> > > results for link autosuggestion. In my design, I think the suggestion
> > > results should be filtered and ranked by the following conditions.
> > > (for example user types "[[mytest" in page "xwiki:main.newpage")
> > > First [[ is triggered, when user keep typing, the page and attachment
> > > suggestion results should be filtered and ranked by the following
> rules:
> > > 1. Prefix matched (only for page name and attachment name)
> > >   - The pages which are in the same wiki and space of the document
> > current
> > > edited.( Prior A)
> > >   - The pages which are in the same wiki but different space of the
> > > document current edited;(Prior B)
> > >   - The pages which are in different wiki and different space of the
> > > document current edited; (Prior C);
> > > 2. Partial matched (only for page name and attachment name)
> > >   - The pages which are in the same wiki and space of the document
> > current
> > > edited.( Prior C)
> > >   - The pages which are in the same wiki but different space of the
> > > document current edited;(Prior D)
> > >   - The pages which are in different wiki and different space of the
> > > document current edited; (Prior E)
> > > 3. If no page and attachment matches the above two rules,  the
> suggestion
> > > box will be disappeared.(eclipse way)
> > >
> > > However, sometimes user might insert the space name too, for example,
> > user
> > > will type "[[Main", following the rule 1 and rule 2, the pages begins
> > with
> > > "Main" will be first retrieved as the suggestion results untill user
> > types
> > > "." after "Main", the suggestion result will be retreved from the pages
> > > under the space "Main" only. Filters still obey the above three rules.
> > > And also when user types "attach:", the suggestion result will be
> > retrieved
> > > the attachments only following the above three rules.
> > > And if the link is under the attachment context, when "@" is typed, the
> > > attachments only will be retrieved following the above three rules.
> > >
> > > In order to do this, I investigated the rest services already existed(
> > > http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI),
> but
> > I
> > > found none is perfect suitable for my needs. So I talk with Marius, he
> > > suggested me to use the existed services which are closed to my needs
> > > first,
> > > and then write the perfect one later.
> > >
> > > However, I only found the rest service:/wikis/{wiki}/search  is the
> most
> > > closed one for the pages suggestion to my needs, there is no attachment
> > > search rest service for attachment suggestion, Marius adviced me to use
> "
> > >
> > >
> >
> http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=plain&query=name:__INPUT__*%20AND%20type:attachment&nb={number}&input={query}<http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=plain&query=name:__INPUT__*%20AND%20type:attachment&nb=%7Bnumber%7D&input=%7Bquery%7D>
> <
> http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=plain&query=name:__INPUT__*%20AND%20type:attachment&nb=%7Bnumber%7D&input=%7Bquery%7D
> >
> > <
> >
> http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=plain&query=name:__INPUT__*%20AND%20type:attachment&nb=%7Bnumber%7D&input=%7Bquery%7D
> > >
> > > "
> > > instead, but I found the search result is in xml format(not json), and
> > also
> > > the information of the results got from SuggestLuceneService is limit.
> > >
> > > I have read the document of how to write custom rest service, but the
> > > information is limit, any one can guide me to run an helloworld?
> > >
> > >
> > >
> > > --
> > > Best wishes,
> > >
> > > 许凌志(Jame Xu)
> > >
> > > MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
> > >
> > > Department of Computer Science and Technology, Xi’an Jiaotong
> University
> > > _______________________________________________
> > > devs mailing list
> > > [email protected]
> > > http://lists.xwiki.org/mailman/listinfo/devs
> > >
> > _______________________________________________
> > devs mailing list
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/devs
> >
>
>
>
> --
> Best wishes,
>
> 许凌志(Jame Xu)
>
> MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
>
> Department of Computer Science and Technology, Xi’an Jiaotong University
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to