incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Barker <norman.bar...@gmail.com>
Subject Re: geocouch
Date Sun, 18 Jul 2010 18:10:11 GMT
I have worked out how to attach these issues directly to geocouch,
great work Volker!

On Sat, Jul 17, 2010 at 1:15 PM, Norman Barker <norman.barker@gmail.com> wrote:
> Hi,
>
> I am using geocouch to index documents and it is working well, I have
> had a couple of issues, firstly you can only emit one spatial key per
> document and it is useful to emit more than one spatial key as you
> parse the document (rather than creating a geojson geometry
> collection).
>
> Secondly, and perhaps more importantly, if you don't emit a spatial
> key then the indexing fails.
>
> In couch_spatial_updater I changed the spatial docs function as below,
> but this should be considered a workaround, I see the bbox to
> [[{{-181.0, -91.0, -181.0, -91.0}, [null]}]]; knowing that won't be
> queried, really I would like to set it to the atom undefined and not
> have it in the index when not emitted.
>
> Final comment is that I was patching a 1.0 windows release, and the
> only 1.0 branch files that are different are couch_view_group and
> couch_query_servers and the changes were -export([hex_sig/1]). and
> -export([get_os_process/1]). if they could get added to trunk then
> perhaps geocouch could be kept as a separate plugin? I was able to put
> the daemons in local.ini and it worked fine.
>
> Good work though, this is cool and is really quick!.
>
> spatial_docs(Proc, Docs) ->
>    % send the documents
>    Results = lists:map(
>        fun(Doc) ->
>            Json = couch_doc:to_json_obj(Doc, []),
>            % NOTE vmx: perhaps should map_doc renamed to something more
>            % general as it can be used for most indexers
>            FunsResults = couch_query_servers:proc_prompt(Proc,
> [<<"map_doc">>, Json]),
>            % the results are a json array of function map yields like this:
>            % [FunResults1, FunResults2 ...]
>            % where funresults is are json arrays of key value pairs:
>            % [[Key1, Value1], [Key2, Value2]]
>            % Convert the key, value pairs to tuples like
>            % [{Key1, Value1}, {Key2, Value2}]
>            case FunsResults of
>              [[]] ->
>                 [[{{-181.0, -91.0, -181.0, -91.0}, [null]}]];
>              _ ->
>                lists:map(
>                    fun(FunRs) ->
>                        % do some post-processing of the result documents
>                        FunRs2 = process_result(FunRs),
>                        %JsonDoc = couch_query_servers:json_doc(Doc),
>                        ?LOG_DEBUG("spatial_docs:~n~p~n~p", [FunRs, FunRs2]),
>                        %[list_to_tuple(FunResult) || FunResult <- [FunRs]]
>                        %[list_to_tuple(FunResult) || FunResult <- [FunRs2]]
>                        [FunRs2]
>                    end,
>                FunsResults)
>            end
>        end,
>        Docs),
>    {ok, lists:filter(fun(X) -> X /= [[]] end, Results)}.
>
> Norman
>

Mime
View raw message