algolia / algoliasearch-jekyll

⚠ DEPRECATED Use jekyll-algolia instead.
https://community.algolia.com/jekyll-algolia/
MIT License
125 stars 12 forks source link

URL not coming back on search #7

Closed borisschapira closed 9 years ago

borisschapira commented 9 years ago

Content URL are clearly indexed, but not looked during a search. That could be problematic if URL is not exactly the slug of the article title.

For exemple, this post : http://borisschapira.com/2014/05/sud-web-2014-de-lidee-au-projet-notes is well indexed. But if you search on Algolia for "sud-web-2014-de-lidee-au-projet-notes", you'll never find it because of the "notes" wich is not in the title.

borisschapira commented 9 years ago

Note: I could not find an example on your demo as all the article have the same URL as their title.

pixelastic commented 9 years ago

Hello,

The search is only done in your attributesToIndex, and by default url is not part of it. You can define a custom list of attributesToIndex in your _config.yml file, under the algolia.settings option.

The default list of attributesToIndex is %w(title h1 h2 h3 h4 h5 h6 unordered(text) unordered(tags)). The order of the attributesToIndex is important. Records with a match in a key at the top will be returned before records with a match in a key at the bottom. Here is how I would do it:

algolia:
  application_id: XXXX
  [...]
  settings:
    attributesToIndex:
      - title
      - h1
      - h2
      - h3
      - h4
      - h5
      - h6
      - unordered(text)
      - unordered(tags)
      - unordered(url)

This should fix your issue :)

pixelastic commented 9 years ago

Oh, actually, using slug instead of url might even be better. When using url a lot of pages might match when searching for html

borisschapira commented 9 years ago

Thanks, it works like a charm. Maybe you should add what you just explained to the plugin documentation ?

pixelastic commented 9 years ago

Yes, good idea. I just updated the documentation : https://github.com/algolia/algoliasearch-jekyll#settings

Thanks for the feedback

borisschapira commented 9 years ago

Nice, thank you !