Using Algolia's JS Helper for search, how would I retrieve a hit result's physical distance from the user's IP address?
In some of Algolia's libraries I see the Results object has a _rankingInfo property that contains the physical distance. However, this property seems to be missing on the Results object when using the JS Helper.
I'm able to rank my results by distance with the following, but I can't actually see what that distance value is:
helper.setQueryParameter('aroundLatLngViaIP', true);
helper.setQueryParameter('aroundPrecision', 1000);
There's a search parameter called getRankingInfo that you can use to retrieve those informations. By default its false, but if you're set it to true, it should be good.
Related
HI I'm new to cloudant (and couch and asking questions on stackoverflow so I hope I manage to be vaguely clear about what I'm asking ) and I'm trying to do probably the second most basic geo task but am hitting a dead end.
I've got a database of docs which are geojson objects, I've created an index so I can query for intersections etc but it seems the only options I have in the url is the format=legacy (gives me the ids) and the format=geojson and the include_docs parameter - what I'd like to do is give back a particular view of the result set - I'm not interested in the geometry of the object (which is a big lump of data and it's likely that a number of other properties may be in the document that I'd rather filter out)
is there a correct way to do this in a single api call or do I need to fetch the doc ids (legacy format) and then issue a second query to bring back my chosen 'view' for each document id given in the result of format=legacy response
Thanks
I am currently working with the Algolia search API and I am unable to figure out how I would limit the results by key value searching + query string. By this i mean this.
I have a list of properties.
Each property belongs to a client.
Within the application If i am looking at a client information card and I want to search for a property that client owns It would make more sense to limit the results to the client and then look for the query string.
I am using MongoDB as my DB and storing the client id as a sub document like so
//Property Document
{
_id : "randomID"
client : {
_id : "randomID",
name : "ClientName"
}
}
If you want to restrict the search to a specific client, I would go for facet filtering to restrict the search to that client only.
Add client._id in the attributesForFaceting in your index settings
Filter your searches with the facetFilters=client._id:MYCLIENTID query parameter
Then, you should also take a look at the Secured API keys which are able to encode such restriction in a secure way (so the end-user cannot patch the JS code and work-around the filtering).
There is parameter called restrictSearchableAttributes[link] to restrict, at query time, search to some attributes only. Nevertheless, in your case I think you'd get more accurate results by putting each client info into a different record (+ the info of the related document).
I have a question about the good way to use pagination with Alfresco.
I know the documentation (https://wiki.alfresco.com/wiki/4.0_JavaScript_API#Search_API)
and I use with success the query part.
I mean by that that I use the parameters maxItems and skipCount and they work the way I want.
This is an example of a query that I am doing :
var paging =
{
maxItems: 100,
skipCount: 0
};
var def =
{
query: "cm:name:test*"
page: paging
};
var results = search.query(def);
The problem is that, if I get the number of results I want (100 for example), I don't know how to get the maxResults of my query (I mean the total amount of result that Alfresco can give me with this query).
And I need this to :
know if there are more results
know how many pages of results are lasting
I'm using a workaround for the first need : I'm doing a query for (maxItems+1), and showing only maxItems. If I have maxItems+1, I know that there are more results. But this doesn't give me the total amount of result.
Do you have any idea ?
With the javascript search object you can't know if there are more items. This javascript object is backed by the class org.alfresco.repo.jscript.Search.java. As you can see the query method only returns the query results without any extra information. Compare it with org.alfresco.repo.links.LinkServiceImpl which gives you results wrapped in PagingResults.
So, as javacript search object doesn't provide hasMoreItems info, you need to perform some workaround, for instance first query without limits to know the total, and then apply pagination as desired.
You can find how many objects have been found by your query simply calling
results.length
paying attention to the fact that usually queries have a configured maximum result set of 1000 entries to save resources.
You can change this value by editing the <alfresco>/tomcat/webapps/alfresco/WEB_INF/classes/alfresco/repository.properties file.
So, but is an alternative to your solution, you can launch a query with no constraints and obtain the real value or the max results configured.
Then you can use this value to devise how many pages are available basing you calculation on the number of results for page.
Then dinamically pass the number of the current page to the builder of your query def and the results variable will contain the corresponding chunk of data.
In this SO post you can find more information about pagination.
I take an string from user and must search its places in whole of world.
I want to use foursquare venues api.
but in that endpoint I must set search ranges by (ll and radius) or (sw and ne) or (near and radius).
now how search places for an string in whole of world ?
You can set the intent parameter to "global":
intent=global
See Venue Search Parameters:
global
Finds the most globally relevant venues for the search, independent of location.
Ignores all parameters other than query and limit.
For example:
https://api.foursquare.com/v2/venues/search?intent=global&query=apple+store&oauth_token=(YOUR_TOKEN)&v=20150721
If you use the global value, all other parameters except query and limit are ignored.
I've created a view that utilizes Search API integration and allows searching node fields. I have related content to ol_locator_location (Location) which is comprised of Address and GeoField. I have indexed the GeoField (ALL possibile iterations including WKT). I'd like to perform Proximity (Distance) searches against the indexed nodes based on the WKT data that is available. The problem is that GeoField:Proximity doesn't seem to relate well.
I'm able to add the GeoField of the related nodes and I'm able to see this on the OpenLayers map but I'm not offered any option for Proximity searching. How can I get this working?
You need to use the search_api_location module. That module adds new abilities to your geopoint filter, namely, being able to specify a point and search for nearby (proximity) places based on a radius.
Alternatively, if you like to program, you can query the solr search yourself and create the view you want using PHP or Javascript.
http://wiki.apache.org/solr/SpatialSearch
http://docs.lucidworks.com/display/solr/Spatial+Search