[xwiki-devs] The problem with the rest services for autosuggestion.
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}" 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
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/xwik... [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... 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> " 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
On Tue, Jul 19, 2011 at 4: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.
We could even make JSON default (and remove the XML altogether) Jerome
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/xwik... [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
" 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
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/xwik... [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
" 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
Hi James, On 07/20/2011 11:08 AM, 许凌志(Jamesxu) wrote:
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.
I believe this is a bug in the SuggestLuceneService code that you could try to fix. You shouldn't discard existing code just because it has a few bugs. XWiki is an open source project and your contribution outside of the GSoC program is more than welcome. The way you want to rank search results is generic and I would love to see it used on the default XWiki search, which is pretty bad right now (not because of Lucene, but because of the way we use Lucene, as I've been told). Thanks, Marius
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/xwik... [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
" 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
2011/7/20 Marius Dumitru Florea <[email protected]>
Hi James,
On 07/20/2011 11:08 AM, 许凌志(Jamesxu) wrote:
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.
I believe this is a bug in the SuggestLuceneService code that you could try to fix. You shouldn't discard existing code just because it has a few bugs. XWiki is an open source project and your contribution outside of the GSoC program is more than welcome.
Yes, I am considering use Xwiki.search for autosuggestion, and I am glad to fix this bug, but Could anyone give me some information about how to fix it, because I am not very familiar with Lucene and also the index structure of xwiki. I am also re-considerting about the rest service, I have tested it yet, it seems works well for autosuggestion, and no bugs have found yet, the attachment search is really good and useful too. And I am also considering that the image autosuggestion and macro suggestion, we will not use lucene, but they will still be retrieved by rest service, if any. So till now, I prefer rest services though the page rest service and attachment rest service can not merge to a single service.
The way you want to rank search results is generic and I would love to see it used on the default XWiki search, which is pretty bad right now (not because of Lucene, but because of the way we use Lucene, as I've been told).
Thanks, Marius
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
_______________________________________________ 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
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
According to Eduard's suggestion, I modify the macro code of SuggestLuceneService, and it works fine when I visit in browser. But it failed when I am trying to get it using ajax, in the ajax response, responseText is the right value get from the server, but the responseJSON is null. Could anyone check the code for me, what is wrong with it, it is really strange. The macro code for SuggestLuceneService: {{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($media = "$!request.media") #if($media != 'json' && $media != 'xml') #set($media = 'xml') #end #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != '' && $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($rawresults = $xwiki.lucene.getSearchResults($query, $util.null)) #set($results = $rawresults.getResults("0", "$nb")) #if($media == 'xml') #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #end #if($media == 'json') #set($discard = $response.setContentType("application/json")) #set($size = $results.size()) [ #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end $velocityCount #if($velocityCount == $size) {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"} #else {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}, #end #end ] #end #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}} The ajax codes: _showSuggestionResults : function(query, position, size) { if(query == null) return; if(query == "") query = "icontest" new Ajax.Request(" http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=... type:wikipage) OR (filename:__INPUT__* AND type:attachment)&nb=30&media=json", { method : 'get', asynchronous : false, parameters : {"input":query}, onSuccess : this._onSuccess.bind(this, position, size, query), onFailure : this._onFailure.bind(this) }); }, _onSuccess : function(position, size, query, response) { var results= response.responseJSON* //undefined* //var results= response.responseText.evalJSON(true); *//parse error* } There is the result file in the attachment, when I get it directly from the browser On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru <[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- Best wishes, 许凌志(Jame Xu) MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University Department of Computer Science and Technology, Xi’an Jiaotong University
Hi James, 2011/7/21 许凌志(Jamesxu) <[email protected]>
According to Eduard's suggestion, I modify the macro code of SuggestLuceneService, and it works fine when I visit in browser. But it failed when I am trying to get it using ajax, in the ajax response, responseText is the right value get from the server, but the responseJSON is null. Could anyone check the code for me, what is wrong with it, it is really strange.
The macro code for SuggestLuceneService: {{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($media = "$!request.media") #if($media != 'json' && $media != 'xml') #set($media = 'xml') #end #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != '' && $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($rawresults = $xwiki.lucene.getSearchResults($query, $util.null)) #set($results = $rawresults.getResults("0", "$nb")) #if($media == 'xml') #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #end #if($media == 'json') #set($discard = $response.setContentType("application/json")) #set($size = $results.size()) [ #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end $velocityCount #if($velocityCount == $size) {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"} #else {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}, #end #end ] #end #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}}
I did not exactly run your code, but on a first look, you seem to be having some javascript problems: The ajax codes:
_showSuggestionResults : function(query, position, size) { if(query == null) return; if(query == "") query = "icontest" new Ajax.Request("
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=... type:wikipage) OR (filename:__INPUT__* AND type:attachment)&nb=30&media=json", { method : 'get', asynchronous : false, parameters : {"input":query},
onSuccess : this._onSuccess.bind(this, position, size, query),
Instead of delegating the onSuccess to a different function, you could use an inline function instead, like: onSuccess : function(transport) { // here you should have access to query, position and size parameters. }
onFailure : this._onFailure.bind(this) }); },
_onSuccess : function(position, size, query, response) {
Here, the problem is that the _onSuccess method accepts 4 paremeters, but you have previously bound it with "this, position, size, query". Adding to this the default parameter of the onSuccess method (transport), you now have 5 parameters. So your _onSuccess method should look like "function(thisFromOnSuccess, position, size, query, transportParameterOfOnSuccess)". You can then use the transport parameter (transportParameterOfOnSuccess) to get the response. You could excldude "this" from "bind(this, position, size, query)" above if you don`t really need it, since this is actually the "_showSuggestionResults" method and it's not that helpful. Hope this helps, Eduard var results= response.responseJSON* //undefined*
//var results= response.responseText.evalJSON(true); *//parse error*
}
There is the result file in the attachment, when I get it directly from the browser
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru <[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
On Tue, Jul 19, 2011 at 8:36 AM, 许凌志(Jamesxu) <
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- 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
Hi James, See below, On 07/21/2011 01:29 PM, 许凌志(Jamesxu) wrote:
According to Eduard's suggestion, I modify the macro code of SuggestLuceneService, and it works fine when I visit in browser. But it failed when I am trying to get it using ajax, in the ajax response, responseText is the right value get from the server, but the responseJSON is null. Could anyone check the code for me, what is wrong with it, it is really strange.
The macro code for SuggestLuceneService: {{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($media = "$!request.media") #if($media != 'json'&& $media != 'xml') #set($media = 'xml') #end #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != ''&& $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($rawresults = $xwiki.lucene.getSearchResults($query, $util.null)) #set($results = $rawresults.getResults("0", "$nb")) #if($media == 'xml') #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #end #if($media == 'json') #set($discard = $response.setContentType("application/json")) #set($size = $results.size()) [ #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end $velocityCount #if($velocityCount == $size) {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}",
"name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}
"path' ? Hope this helps, Marius
#else {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}, #end #end ] #end #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}}
The ajax codes: _showSuggestionResults : function(query, position, size) { if(query == null) return; if(query == "") query = "icontest" new Ajax.Request(" http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=... type:wikipage) OR (filename:__INPUT__* AND type:attachment)&nb=30&media=json", { method : 'get', asynchronous : false, parameters : {"input":query}, onSuccess : this._onSuccess.bind(this, position, size, query), onFailure : this._onFailure.bind(this) }); },
_onSuccess : function(position, size, query, response) { var results= response.responseJSON* //undefined* //var results= response.responseText.evalJSON(true); *//parse error* }
There is the result file in the attachment, when I get it directly from the browser
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi James, As a good practice when dealing with JSON in the browser, here is what you can do : * Check the AJAX response in Firebug. If you don't see a "JSON" tab, then something is wrong (the JSON is not valid). What you can do then is copy the response body from Firebug and submit it on JSONLint (http://jsonlint.com/). It will tell you what's wrong. Hope this helps Jerome 2011/7/21 许凌志(Jamesxu) <[email protected]>
According to Eduard's suggestion, I modify the macro code of SuggestLuceneService, and it works fine when I visit in browser. But it failed when I am trying to get it using ajax, in the ajax response, responseText is the right value get from the server, but the responseJSON is null. Could anyone check the code for me, what is wrong with it, it is really strange.
The macro code for SuggestLuceneService: {{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($media = "$!request.media") #if($media != 'json' && $media != 'xml') #set($media = 'xml') #end #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != '' && $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($rawresults = $xwiki.lucene.getSearchResults($query, $util.null)) #set($results = $rawresults.getResults("0", "$nb")) #if($media == 'xml') #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #end #if($media == 'json') #set($discard = $response.setContentType("application/json")) #set($size = $results.size()) [ #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end $velocityCount #if($velocityCount == $size) {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"} #else {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}, #end #end ] #end #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}}
The ajax codes: _showSuggestionResults : function(query, position, size) { if(query == null) return; if(query == "") query = "icontest" new Ajax.Request("
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=... type:wikipage) OR (filename:__INPUT__* AND type:attachment)&nb=30&media=json", { method : 'get', asynchronous : false, parameters : {"input":query}, onSuccess : this._onSuccess.bind(this, position, size, query), onFailure : this._onFailure.bind(this) }); },
_onSuccess : function(position, size, query, response) { var results= response.responseJSON* //undefined* //var results= response.responseText.evalJSON(true); *//parse error* }
There is the result file in the attachment, when I get it directly from the browser
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru <[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
On Tue, Jul 19, 2011 at 8:36 AM, 许凌志(Jamesxu) <
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- 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
Thanks all very much, I have solve the problem. The suggestion can use real datas now. 2011/7/21 Jerome Velociter <[email protected]>
Hi James,
As a good practice when dealing with JSON in the browser, here is what you can do :
* Check the AJAX response in Firebug. If you don't see a "JSON" tab, then something is wrong (the JSON is not valid). What you can do then is copy the response body from Firebug and submit it on JSONLint (http://jsonlint.com/ ). It will tell you what's wrong.
Hope this helps
Jerome
2011/7/21 许凌志(Jamesxu) <[email protected]>
According to Eduard's suggestion, I modify the macro code of SuggestLuceneService, and it works fine when I visit in browser. But it failed when I am trying to get it using ajax, in the ajax response, responseText is the right value get from the server, but the responseJSON is null. Could anyone check the code for me, what is wrong with it, it is really strange.
The macro code for SuggestLuceneService: {{velocity}} #set($query = "$!request.query") #set($input = "$!request.input") #set($media = "$!request.media") #if($media != 'json' && $media != 'xml') #set($media = 'xml') #end #set($nb = "$!request.nb") #if($nb != '') #set($nb = $util.parseInt($nb) + 1) #else #set($nb = 6) #end #if($query != '' && $input != '') #set($query = $query.replaceAll('__INPUT__', $input)) #set($rawresults = $xwiki.lucene.getSearchResults($query, $util.null)) #set($results = $rawresults.getResults("0", "$nb")) #if($media == 'xml') #set($discard = $response.setContentType("text/xml")) <?xml version="1.0" encoding="UTF-8"?> <results> #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end <rs id="$url" info="${escapetool.xml($itemdoc.fullName)}">$escapetool.xml($name)</rs> #end </results> #end #if($media == 'json') #set($discard = $response.setContentType("application/json")) #set($size = $results.size()) [ #foreach($item in $results) #set($itemfullname = "${item.wiki}:${item.space}.${item.name}") #set($itemdoc = $xwiki.getDocument($itemfullname)) #if($item.type == "attachment") #set($name = $item.filename) #set($url = $itemdoc.getAttachmentURL($name)) #else #set($name = $itemdoc.getDisplayTitle()) #set($url = $itemdoc.getURL()) #end $velocityCount #if($velocityCount == $size) {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"} #else {"id":"$url", "info":"${escapetool.xml($itemdoc.fullName)}", "name":"${item.name}", "path':"$itemfullname", "type":"$item.type"}, #end #end ] #end #else {{info}} This service allows to retrieve search results for the suggest UI component. Examples: * [[$doc.getExternalURL('get', 'outputSyntax=plain&query=__INPUT__*&input=test')]] {{/info}} #end {{/velocity}}
The ajax codes: _showSuggestionResults : function(query, position, size) { if(query == null) return; if(query == "") query = "icontest" new Ajax.Request("
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
type:wikipage) OR (filename:__INPUT__* AND type:attachment)&nb=30&media=json", { method : 'get', asynchronous : false, parameters : {"input":query}, onSuccess : this._onSuccess.bind(this, position, size, query), onFailure : this._onFailure.bind(this) }); },
_onSuccess : function(position, size, query, response) { var results= response.responseJSON* //undefined* //var results= response.responseText.evalJSON(true); *//parse error* }
There is the result file in the attachment, when I get it directly from the browser
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru <[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
On Tue, Jul 19, 2011 at 8:36 AM, 许凌志(Jamesxu) <
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- 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
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. On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru <[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- Best wishes, 许凌志(Jame Xu) MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University Department of Computer Science and Technology, Xi’an Jiaotong University
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/xwik... 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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/
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/xwik...
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' 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 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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ 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
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/xwik...
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/
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists. Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size() > 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index > 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}} as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags. Can anyone tell me why? 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/xwik...
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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
" 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ 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
On 07/27/2011 12:24 PM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why?
James, you have to call the page like you did with your initial fake link suggestion service and with the XWiki.SuggestLuceneService page: ?xpage=plain&outputSyntax=plain Hope this helps, Marius
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/xwik...
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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
[2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
[4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
> > " > 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
2011/7/27 Marius Dumitru Florea <[email protected]>
On 07/27/2011 12:24 PM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why?
James, you have to call the page like you did with your initial fake link suggestion service and with the XWiki.SuggestLuceneService page: ?xpage=plain&outputSyntax=plain
Yes, I have tried the url: http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?xpage=plain&out... but still can't get the right result.
Hope this helps, Marius
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/xwik...
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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
> [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin > [3] > >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
> [4] > >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
> > > 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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
> > < >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>> >> " >> 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ 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
On 07/27/2011 04:30 PM, 许凌志(Jamesxu) wrote:
2011/7/27 Marius Dumitru Florea<[email protected]>
On 07/27/2011 12:24 PM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why?
James, you have to call the page like you did with your initial fake link suggestion service and with the XWiki.SuggestLuceneService page: ?xpage=plain&outputSyntax=plain
Yes, I have tried the url: http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?xpage=plain&out... but still can't get the right result.
What about http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?outputSyntax=pl... ?
Hope this helps, Marius
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/xwik...
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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
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/xwik...
>> [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin >> [3] >> >> >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>> [4] >> >> >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>> >> >> 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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
> > < >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>> >> < >> >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>> >>> " >>> 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Wed, Jul 27, 2011 at 10:04 PM, Marius Dumitru Florea < [email protected]> wrote:
On 07/27/2011 04:30 PM, 许凌志(Jamesxu) wrote:
2011/7/27 Marius Dumitru Florea<[email protected]>
On 07/27/2011 12:24 PM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why?
James, you have to call the page like you did with your initial fake link suggestion service and with the XWiki.SuggestLuceneService page: ?xpage=plain&outputSyntax=plain
Yes, I have tried the url:
http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?xpage=plain&out...
but still can't get the right result.
What about
http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?outputSyntax=pl... ?
Still got the results which are not excepted: Name Recently Modified Panel type view Category Information Description Content
Hope this helps, Marius
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/xwik...
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
On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote:
> 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/xwik...
>>> [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin >>> [3] >>> >>> >> >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>>> [4] >>> >>> >> >
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>>> >>> >>> 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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
> < >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>> >> < >> >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>> >>> < >>> >> >
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>>> >>>> " >>>> 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 >
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ 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
On 07/27/2011 05:26 PM, 许凌志(Jamesxu) wrote:
On Wed, Jul 27, 2011 at 10:04 PM, Marius Dumitru Florea< [email protected]> wrote:
On 07/27/2011 04:30 PM, 许凌志(Jamesxu) wrote:
2011/7/27 Marius Dumitru Florea<[email protected]>
On 07/27/2011 12:24 PM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why?
James, you have to call the page like you did with your initial fake link suggestion service and with the XWiki.SuggestLuceneService page: ?xpage=plain&outputSyntax=plain
Yes, I have tried the url:
http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?xpage=plain&out...
but still can't get the right result.
What about
http://localhost:8080/xwiki/bin/get/Panels/Recently+Modified?outputSyntax=pl... ?
Still got the results which are not excepted:
Name Recently Modified Panel type view Category Information Description
Content
Indeed. First you need to review the velocity code because some blocks are not properly nested. Then you need to edit in wiki mode and set the content to: ----------8<---------- {{velocity}} #if ("$!request.media" == '') {{include document="Panels.PanelSheet"/}} #else #set($content = $doc.getObject('Panels.PanelClass').getProperty('content').value) $doc.getRenderedContent($content, $doc.syntax.toIdString(), 'plain/1.0') #end {{velocity}} ---------->8---------- Hope this helps, Marius
Hope this helps, Marius
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/xwik...
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
> On Wed, Jul 20, 2011 at 5:56 PM, Eduard Moraru<[email protected]> wrote: > >> 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/xwik...
>>>> [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin >>>> [3] >>>> >>>> >>> >>
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>>>> [4] >>>> >>>> >>> >>
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
>>>> >>>> >>>> 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=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
<
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
> >> < >>
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>> >>> < >>> >>
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>>> >>>> < >>>> >>> >>
http://localhost:8080/xwiki/bin/get/XWiki/SuggestLuceneService?outputSyntax=...
>>>>> >>>>> " >>>>> 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 >> > > >
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 07/27/2011 05:24 AM, 许凌志(Jamesxu) wrote:
I found that if there is no input for lucene query, no results will be returned. But In link suggestion, when user first type "[[", there is no queries, so no suggestions will be got, but Marius and I excepted there is a default suggestion results for users, like the recent modified pages, and the attachments belong to the current edited pages if exists.
Yes, this is a limitation of the Lucene engine, you can't use only * as a query term. You should drop the filter when the query stub is empty, for example: filename:__INPUT__* should be removed if the input is empty.
Marius give me wiki page: Panels.Recently Modified, there is an page object for getting the Recently Modeified pages. I have tried to enhance this object so that it can return json results which can be used as a web service, so I edit the content of the object of this page, the code is below: {{velocity}} *#set($media = "$!request.media")* #set ($recentlyModified = $xwiki.searchDocuments('where 1=1 order by doc.date desc', 5, 0)) #if ($recentlyModified.size()> 0 || $showEmptyPanels) *#if($media == 'json') $response.setContentType("application/json") {'test':'mytest'}* #else #panelheader($msg.get('panels.recentlyModified.title')) #foreach ($docname in $recentlyModified) #if ($xwiki.hasAccessLevel('view', $xcontext.getUser(), $docname)) #set ($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if ($foreach.index> 0) (% class="pitemseparator" %) ~| (%%)## #end (% class="panelitem" %)[[$rdoc.plainTitle>>$rdoc]](%%)## #end #end #end #panelfooter() #end {{/velocity}}
as you can see, I add an parameter named "media", if the media is json, then return the json file, otherwise the default behaviour will be executed. I tested the code above, and the json result is not "*{'test':'mytest'}*", but contains some other html tags.
Can anyone tell me why? -- Sergiu Dumitriu http://purl.org/net/sergiu/
On 07/20/2011 04:08 AM, 许凌志(Jamesxu) wrote:
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.
This is "normal". Lucene indexes several fields for each entity (document or attachment), and this includes the owner document name for attachments. When searching, by default our Lucene plugin searches in all indexed fields, so it's normal that searching for "jame" the attachment registers as a "hit", since one of its fields, the owner document name, matches the searched term. If you want to search only in the attachment name, then the query passed to the search plugin should be: filename:jame*
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/xwik... [2] http://extensions.xwiki.org/xwiki/bin/view/Extension/Lucene+Plugin [3]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [4]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik...
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=...
" 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
-- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (5)
-
Eduard Moraru -
Jerome Velociter -
Marius Dumitru Florea -
Sergiu Dumitriu -
许凌志(Jamesxu)