Hibernating Rhinos

Zero friction databases

Feature explained–Spatial Geocode from address

In August we added the option in spatial queries to get the Geocode by address.

We already did something like that in the “Events” page in the RavenDB website and It was quite easy with the Google Maps API.

However when we tried to implement it in the studio we discovered that to do that in Silverlight is not as simple.

Apparently in order to get Google API to work with Silverlight you need to set a bridge server that has the appropriate clientaccesspolicy.xml because the settings on the Google API server does not match the permissions required for Silverlight.

So we looked for another service that has the settings that allowed to work with Silverlight without any complications, what we found is that the Yahoo! Maps Geocoding does just that.

The setting of the Yahoo API was even easier then Google’s and is done like this:

   1: var url = "http://where.yahooapis.com/geocode?flags=JC&q=" + queryModel.Address;
   2:             var webRequest = WebRequest.Create(new Uri(url, UriKind.Absolute));
   3:             webRequest.GetResponseAsync().ContinueOnSuccessInTheUIThread(doc =>
   4:             {
   5:                 RavenJObject jsonData;
   6:                 using (var stream = doc.GetResponseStream())
   7:                 {
   8:                     jsonData = RavenJObject.Load(new JsonTextReader(new StreamReader(stream)));
   9:                 }
  11:                 var result = jsonData["ResultSet"].SelectToken("Results").Values().FirstOrDefault();
  13:                 if (result != null)
  14:                 {
  15:                     queryModel.Latitude = double.Parse(result.Value<string>("latitude"));
  16:                     queryModel.Longitude = double.Parse(result.Value<string>("longitude"));
  17:                 }
  19:             }).Catch();

As you can see it is simply a web request with a default url with the addition of the address

For mode information about the Yahoo geocode API: http://developer.yahoo.com/maps/rest/V1/geocode.html

New Option in the RavenDB Studio–Patching

Not long ago we added the option to do Eval Patching in RavenDB (see: http://ayende.com/blog/157185/awesome-ravendb-feature-of-the-day-evil-patching)

Recently we added this option to the studio.

Now when you open the studio you will see a new tab in the options for “Patch”


Once there you will see the next screen:



As you can see this page has many options so lets look at them separately


At the top left you have this toolbar with several options, the first one is a combo-box where you can choose what you want to patch (“Document”, “Collection” or “Index”).

Next to it you have the “Test” Option, with this option (which will only be available after selecting a document to check the patch on) when we click on this button the fields on the bottom of the screen (titled “Before Patch” and “After Patch”) will be populated with the selected document and how will it be after we patch.

Next we have the “Save” and “Load” options. With those you can save this page setting and load them again for later use.

Next we have the Patch option that executes the Patch command (this will save the changes to the database)

Let’s look at a small example of patching:

In this case I want to change the Genre name from “Rock” to “Rock and Roll”, after I pressed “Test” I got the screen below, as you can see the “Name” is different.


as you can see on the right of the script we have the “Parameters” list, in there I can do this patch in a different way:


Now I as you can see we added another value to the document with the help of parameters.


Now lets go over the changes when using “Collection”


In “Collection” you can see that the “Patch” option changed into 2 options: “Patch Selected” and “Patch All”.

In order to patch only some of the items in the collection you can select then in the “Matching Documents”  section that was added to the page.

Another thing we have is the option to select on which collection we want to patch.


And last we have the option to patch by index:


In addition to the changes we had for “Collection” we now have a field “Query” for the index and the patch will apply only to the documents that match this query (and the “Matching Documents” will update accordingly).