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

  • Home
  • SEARCH
  • 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 8976901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:15:05+00:00 2026-06-15T19:15:05+00:00

i using this part of code to getting docs from sphinx but sphinx Query

  • 0

i using this part of code to getting docs from sphinx but sphinx Query always return None. But if i execute code from command line i get correct result, what wrong?

def search_query(query, offset=0):
    mode = SPH_MATCH_EXTENDED
    host = 'localhost'
    port = 9312
    index = 'rss_item'
    filtercol = 'group_id'
    filtervals = []
    sortby = '-@weights'
    groupby = 'id'
    groupsort = '@group desc'
    limit = 30

    # do query
    cl = SphinxClient()
    cl.SetServer ( host, port )
    cl.SetWeights ( [100, 1] )
    cl.SetMatchMode ( mode )

    #cl.SetSortMode(SPH_SORT_TIME_SEGMENTS)
    if limit:
        cl.SetLimits ( offset, limit, max(limit,1000) )
    res = cl.Query ( query, index )

    docs =[]
    for item in res['matches']:
        docs.append(item['id'])

    return docs

# this is django view
def search(request):
    q = request.GET.get('q', '')
    offset = int(request.GET.get('older', 0))
    docs=search_query(q, offset)

    result = Item.objects.filter(id__in=docs).all()

    objects = dict([(obj.id, obj) for obj in result])
    sorted_objects = [objects[id] for id in docs]

    result = sorted_objects

    return render_to_response('rss/_items.html',
                              {'latest_items':result, 'offset':offset+30,'q':q},
                              context_instance=RequestContext(request))

Server : centos6, sphinx: 2.0.5, django: 1.4.2 , apache/wsgi

  • 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-15T19:15:06+00:00Added an answer on June 15, 2026 at 7:15 pm

    resolve issue, by turn Selinux OFF and restart server, i listen to apache process by this command:

    ps auxw | grep httpd | awk '{print"-p " $2}' | xargs strace
    

    and see permission denied for access apache to sphinx and memcache

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

Sidebar

Related Questions

im getting a weird error using this code (part of a class): from sys
The code we're using is straightforward in this part of the search query: myCriteria.Add(
I am using this part of c code in carbide c/c++ char c1[]={0x01}; char
I'm using this part of code in my system. double countA = 0.00; double
I am getting into trouble with this part of code. In fact I want
I am using this code to send mail with php http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html#ss_part_4 . This code
I am using this condition as part of my where clause: exists (select *
I can run tasks as part of our functional tests just fine using this
I'm trying to setup the application server part of C2DM push messaging using this
I'm using AVAudioPlayer to play sound effects in an iPhone game. This is part

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.