Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Sphinx Search Beginner's Guide

You're reading from  Sphinx Search Beginner's Guide

Product type Book
Published in Mar 2011
Publisher
ISBN-13 9781849512541
Pages 244 pages
Edition 1st Edition
Languages
Author (1):
Abbas Ali Abbas Ali
Profile icon Abbas Ali

Table of Contents (15) Chapters

Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Setting Up Sphinx 2. Getting Started 3. Indexing 4. Searching 5. Feed Search 6. Property Search 7. Sphinx Configuration 8. What Next?

Grouping search results


At times we may need to group our search results by an attribute. For example, to show monthly statistics about our blog posts we will need to group the posts by publish_date, or to show count of books by a particular author we will need to group the search results by author.

Sphinx offers a grouping mode which is enabled with SetGroupBy() API call. All matches are assigned to different groups based on group-by value when grouping is used.

Different functions are available to compute the group-by value:

  • SPH_GROUPBY_DAY: Extracts year, month, and day in YYYYMMDD format from the timestamp attribute

  • SPH_GROUPBY_WEEK: Extracts year and first day of the week number in YYYYNNN format from timestamp

  • SPH_GROUPBY_MONTH: Extracts year and month in YYYYMM format from timestamp

  • SPH_GROUPBY_YEAR: Extracts year in YYYY format from timestamp

  • SPH_GROUPBY_ATTR: Attribute value is used for grouping

The function to be used for grouping is:

SetGroupBy ( $attribute, $func, $groupsort...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}