You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Aurélien Bénel <au...@utt.fr> on 2012/09/10 15:55:19 UTC
Rewrite with startkey, endkey and \u9999
Hi everyone, hi Benoît,
As the output of a view, we have:
...
["en", "cry,"] ...
["en", "curious oil within;"] ...
["en", "curse the ground any mor"] ...
...
Note: I use here a simplified syntax. The first column is for keys.
To use this view as an exact phrase "search engine", we build requests like:
_view/foo?startkey=["en","curious oil"]&endkey=["en","curious oil\u9999"]
Now, we would like to rewrite this request from:
search?language=en&query=curious oil
This seems that we would need something similar to:
{
"from": "search",
"to": "_view/foo",
"query": {
"startkey": [":language",":query"],
"endkey": [":language",":query\u9999"]
}
}
Is there any way to tell CouchDB that \u9999 is not a part of the variable name?
Regards,
Aurélien
Re: Rewrite with startkey, endkey and \u9999
Posted by Keith Gable <zi...@ignition-project.com>.
Well, I like Lucene, but that doesn't really help your problem at all :)
---
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Storage+ Certified Professional
Mobile Application Developer / Web Developer
On Mon, Sep 10, 2012 at 10:58 AM, Aurélien Bénel <au...@utt.fr>wrote:
> > Doesn't [] come after \u9999? Couldn't you do this?
> > startkey=["language", "query"]
> > endkey=["language", "query", []]
>
>
> Thanks Keith. I tried a variant of it before. This trick is known to work
> for compound keys equality, but it doesn't work for startsWith queries
> since ["en", "curious oil within;"] > ["en", "curious oil", []]
>
> However, it could be a good idea to use a special character that wouldn't
> be parsed with the parameter name by the rewrite handler.
> I just tried the tilde in vain:
>
> {
> "from": "search",
> "to": "_view/foo",
> "query": {
> "startkey": [":language",":query"],
> "endkey": [":language",":query~"]
> }
> }
>
> What seems weird to me is that it doesn't work with "/" either. Even if it
> would be a bad idea in general, in this case it should be sorted after the
> space, and I thought slashes were parsed as separators by the rewrite
> handler.
>
> Any other ideas?
>
>
> Regards,
>
> Aurélien
Re: Rewrite with startkey, endkey and \u9999
Posted by Aurélien Bénel <au...@utt.fr>.
> Doesn't [] come after \u9999? Couldn't you do this?
> startkey=["language", "query"]
> endkey=["language", "query", []]
Thanks Keith. I tried a variant of it before. This trick is known to work for compound keys equality, but it doesn't work for startsWith queries since ["en", "curious oil within;"] > ["en", "curious oil", []]
However, it could be a good idea to use a special character that wouldn't be parsed with the parameter name by the rewrite handler.
I just tried the tilde in vain:
{
"from": "search",
"to": "_view/foo",
"query": {
"startkey": [":language",":query"],
"endkey": [":language",":query~"]
}
}
What seems weird to me is that it doesn't work with "/" either. Even if it would be a bad idea in general, in this case it should be sorted after the space, and I thought slashes were parsed as separators by the rewrite handler.
Any other ideas?
Regards,
Aurélien
Re: Rewrite with startkey, endkey and \u9999
Posted by Keith Gable <zi...@ignition-project.com>.
Doesn't [] come after \u9999? Couldn't you do this?
startkey=["language", "query"]
endkey=["language", "query", []]
---
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Storage+ Certified Professional
Mobile Application Developer / Web Developer
On Mon, Sep 10, 2012 at 9:37 AM, Aurélien Bénel <au...@utt.fr>wrote:
> > How about, _view/foo?startkey=["en","curious
> oil"]&endkey=["en","curious oil"* +"\u9999"*]
>
> Thanks for the answer. Well, this is the idea, but it must be
> understandable by the rewrite handler.
> Moreover, rewrite rules must be formatted as valid JSON...
>
>
> Regards,
>
> Aurélien
>
>
>
Re: Rewrite with startkey, endkey and \u9999
Posted by Aurélien Bénel <au...@utt.fr>.
> How about, _view/foo?startkey=["en","curious oil"]&endkey=["en","curious oil"* +"\u9999"*]
Thanks for the answer. Well, this is the idea, but it must be understandable by the rewrite handler.
Moreover, rewrite rules must be formatted as valid JSON...
Regards,
Aurélien
Re: Rewrite with startkey, endkey and \u9999
Posted by Robert Keane <ke...@gmail.com>.
How about, _view/foo?startkey=["en","curious oil"]&endkey=["en","curious
oil"* +"\u9999"*]
On Mon, Sep 10, 2012 at 9:55 AM, Aurélien Bénel <au...@utt.fr>wrote:
> Hi everyone, hi Benoît,
>
> As the output of a view, we have:
> ...
> ["en", "cry,"] ...
> ["en", "curious oil within;"] ...
> ["en", "curse the ground any mor"] ...
> ...
>
> Note: I use here a simplified syntax. The first column is for keys.
>
> To use this view as an exact phrase "search engine", we build requests
> like:
> _view/foo?startkey=["en","curious oil"]&endkey=["en","curious oil\u9999"]
>
> Now, we would like to rewrite this request from:
> search?language=en&query=curious oil
>
> This seems that we would need something similar to:
> {
> "from": "search",
> "to": "_view/foo",
> "query": {
> "startkey": [":language",":query"],
> "endkey": [":language",":query\u9999"]
> }
> }
>
> Is there any way to tell CouchDB that \u9999 is not a part of the variable
> name?
>
>
> Regards,
>
> Aurélien