Reputation: 491
i have been trying to filter the suggestions according to location but unsuccessful. i want to show all locations, city , town, villages of country : India
what changes should i do to the below code for it ?
<script type="text/javascript">
$("#myinput")
.suggest({
"key": "my key",
filter: '(any type:/location/location )'
})
.bind("fb-select", function(e, data) {
alert(data.name + ", " + data.id + " (" + data['n:type'].name + ")");
});
</script>
Upvotes: 1
Views: 313
Reputation: 10540
Shawn's approach will work for topics which have the containment properties set up correctly, but I'm not sure how good the coverage is there. I suspect simple geo data (lat/lon) coverage is better. If you want to just filter on distance from the centroid of India, you could do something like:
filter=(all type:/location/location (within radius:500km+lon:82.7948 lat:21.7866))
Note that this is very sketchily documented and I'm not sure whether that means it's brand new and the documentation isn't finished or deprecated and about to go away.
Upvotes: 1
Reputation: 4603
The way to do this with a search filter is to use the part_of
Metaschema predicate like this:
<script type="text/javascript">
$("#myinput")
.suggest({
"key": "my key",
filter: '(all type:/location/location part_of:/m/03rk0)'
})
.bind("fb-select", function(e, data) {
alert(data.name + ", " + data.id + " (" + data['n:type'].name + ")");
});
</script>
The part_of
Metaschema predicate is transitive which means that it matches Freebase topics that are part_of
India (/m/03rk0) or part_of
a location which is part_of
India, etc.
Upvotes: 1