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 6326665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:08:03+00:00 2026-05-24T17:08:03+00:00

I have a text field in my web app that allows users to find

  • 0

I have a text field in my web app that allows users to find other people by name. You start typing in the box and the server sends back possible matches as you type. I set up Haystack / Solr backend with a simple search index:

class UserIndex(SearchIndex):
    text = NgramField(document=True, model_attr='get_full_name')

site.register(BerlinrUser, UserIndex)

Then I run manage.py build_solr_schema, copy the schema to my solf/conf directory, restart solr, then finally run manage.py update_index.

In my django view, I have the following search code:

q = request.GET.get("q")
search_result = SearchQuerySet().models(User).autocomplete(content=q)
for result in search_result:
    # Collect user IDs, pull from database, and send back a JSON result

The problem is that the autocomplete does not return what I want. Given this collection of users:

John Smith
John Jingleheimer-Schmidt
Jenny Smith

Here is the behavior that I want:

Query:        Expected result:
"John"        "John Smith",                     
              "John Jingleheimer-Schmidt"
"Smith"       "John Smith",
              "Jenny Smith"
"Smi"         "John Smith",
              "Jenny Smith"
"J"           <Anybody with a first or last name that begins with "J">
"John Sm"     "John Smith"

Note, it is acceptable for the query “ohn Smi” to not return anything, as opposed to matching “John Smith”.

However, using Haystack/Solr, “Smi”, “J”, and “John Sm” return no results at all. To get Haystack/Solr to return anything, I have to use whole words. According to the Haystack documentation, I should use the NgramField to match across word boundaries, but it doesn’t appear to be doing that. Any ideas?

  • 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-05-24T17:08:03+00:00Added an answer on May 24, 2026 at 5:08 pm

    Found out why the query wasn’t working as expected.

    My first problem was in the index definition. It should have looked like this:

    class UserIndex(SearchIndex):
        text = CharField(document=True)
        name_auto = NgramField(model_attr='get_full_name')
    

    Another problem was in my Solr schema.xml file. The minGramSize was set to “3”, which would prevent queries under 3 characters from working. Setting it to “1”, restarting Solr, and rebuilding the index fixed the problem.

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

Sidebar

Related Questions

I have developed an app that allows the user to fill out text fields
I have a text field in my web app where I want to do
I have a text input field like text box or text area. I want
I'm working on a mobile phone web app and I have several text fields
In my web app, users can input text data. This data can be shown
I have a data entry web app where the control that has focus is
We have a web page (HTML javascript and PHP mostly) that allows a user
I am creating a web page where I have an input text field in
I have a web app that takes some client info and produces a letter
OK So I have a web app with a dropdown field, a show button

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.