2

I have the following Algolia request:

index.setSettings({                     
                    getRankingInfo : 1,
                    attributesToIndex:"name,colour,style,material,category",
                    hitsPerPage: 50,
                    ignorePlurals : false,
                    attributesToRetrieve : "objectID",
                    restrictSearchableAttributes : 
                        "name,colour,style,material,category",
                    typoTolerance: "strict",
                    queryType: "prefixNone",
                    page : skipParameter
    });

 index.search(query, function(error, content) {
    ....
 })

However, some of the settings don't seem to be applied to the search. For instance, it retrieves all attributes and I'm pretty sure the searchable attributes aren't restricted. Furthermore, the ranking info isn't returned as can be seen by the returned JSON with the hits post-emptied which means it is definitely not accepting at least that setting.

{"hits":[],"nbHits":173,"page":0,"nbPages":4,"hitsPerPage":50,"processingTimeMS":3,
"query":"Red sofa","params":"query=Red%20sofa"}

I'm running this code in a Parse.com cloud code search method if that may have an effect on the outcome?

henser
  • 3,307
  • 2
  • 36
  • 47
Rambatino
  • 4,716
  • 1
  • 33
  • 56

1 Answers1

4

There is some syntax errors. First attributesToIndex should be an array:

'attributesToIndex': ["name", "colour", "style", "material", "category"]

same for restrictSearchableAttributes

Also you can get a response from algolia when you set settings, so you would be able to see errors with the config. ex:

index.setSettings({
  'customRanking': ['desc(followers)']
}, function(err, content) {
  console.log(content);
});

Some helpful resources:

And be sure to use the latest version of Algolia JS client

https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x

Happy sunday coding! :)

Q Caron
  • 952
  • 13
  • 26
Shipow
  • 2,451
  • 1
  • 21
  • 28
  • Hi Shipow, the documentation says you can have either: "List of attributes you want to use for textual search (must be a subset of the attributesToIndex index setting). Attributes are separated with a comma (for example "name,address" )," – Rambatino May 10 '15 at 12:59
  • I've also added that function call back but it isn't being called – Rambatino May 10 '15 at 13:00
  • Also, that JSON i printed above is the 'content' of the request – Rambatino May 10 '15 at 13:02
  • Either way, if it takes the hitsPerPage into consideration, why isn't it taking the getRankingInfo? – Rambatino May 10 '15 at 13:03
  • And I originally had it as an array but it wasn't making any difference – Rambatino May 10 '15 at 13:05
  • some parameters are overridable at query time. – Shipow May 10 '15 at 13:47
  • + _rankingInfo are stocked in each hits hits[0]['_rankingInfo']: { nbTypos: 0,firstMatchedWord: 0, proximityDistance: 0, userScore: 5584, geoDistance: 0,…} – Shipow May 10 '15 at 13:49