Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:38:19+00:00 2026-06-13T01:38:19+00:00

I am using sphinx to return results to an autocomplete list. When returned the

  • 0

I am using sphinx to return results to an autocomplete list. When returned the results are being cached client side to avoid unnecessary hits to the server.

The logic is as follows:

  1. Perform client side fuzzymatch algorithm on cached results and display in autocomplete
  2. if matches.length < 4 perform ajax request and use sphinx to get more results up to a total of 4
  3. return results and append to autocomplete list

Currently in the ajax request I am sending an array of ID’s that were matched in the client side cache and using PHP to loop through sphinx’s results and remove them from the matches.

This is not only inefficient but of course gives me problems with regards to limiting the results correctly.

What I would like to be able to do is exclude these particular ID’s from the Sphinx matches themselves so that the limit clause is actually relevant.

So the question actually is, how can I exclude certain ID’s within a Sphinx query using the PHP api. e.g. “find all matches with the username John except if they have any of the following ID’s….”

I’ve been right through the sphinx documentation and have read a fair amount on “extended mode” matching and using the various operators however I have found myself getting quite confused and am unsure on how to proceed.

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:38:20+00:00Added an answer on June 13, 2026 at 1:38 am

    Here is the good way to do it with sphinx:

    “Currently in the ajax request I am sending an array of ID’s that were matched in the client side cache and using PHP to loop through sphinx’s results and remove them from the matches.”

    You need to use setfilter in sphinx

    $cl->SetFilter ( $attribute, $values, $exclude=false );
    

    Here $cl is the object of sphinx class

    $attribute is attribute name on which you want to apply filter.

    $values must be a plain array containing integer values. (here you can pass your array)

    exclude this is very important parameter, if you want to exclude all ids from results you provided in array (3rd parameter) then set it as true.

    Ex:
    $cl->SetFilter ( $attribute, $values, true);

    Hope this help!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get sphinx search to return excerpts of matched documents. I'm using
I'm using sphinx to list me some items from my database here. It's almost
When using the PHP Sphinx client this works: SphinxClient::query ('*', 'index1'); But when I
I'm using Thinking Sphinx in a Rails application combined with the jQuery autocomplete plugin
I'm using Sphinx to search MySQL. One of the results Sphinx returns for a
I have a website that is using Sphinx search server to search through a
So, when using Sphinx searches are limited to 1000 results. But, if there are
I am using Sphinx Search . It's working fine for me except one problem:
I am currently writing some extensive documentation using Sphinx for a rather complex Django
I've been documenting a software package using Sphinx and reStructuredText . Within my documents,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.