What are the rules - you say that a query string of '10FTK' should match '10FTH86RSK', but also '10FTK', '10F6TK', '10FTK4'

I think the problem is that the rules aren't 100% clear.

 * For '10FTK' to match '10FTH....' you actually only care about the
   first 4 characters ?
 * For '10FTK' to match '10FTK...' implies you care about the first 5
 * For '10FTK' to match '10F6TK...' implies you care about your 5
   characters with an option numeric inserted after char 3 ?

so - should it match '106FTK ...' or '10TFK' or '10F99TK'

I can suggest a few strategies :

 * With English spelling it is not common for a knowledgable to get the
   first letter wrong - so you could find that the user will know they
   want '10...' and that the 'FTK' bit might be mis-remembered - so
   search on the first two characters only.
 * Use the entered code to build a more fuzzy search - so 10FTK becomes
   something like r'10*F.*T.*(K|H)' (for instance starting with the
   characters '10' and looking for FTK or FTH with possible intervening
   options.
 * Typically long code words are difficult to remember - - is it
   possible that '10FTH86RSK' actually represents a concept that can be
   categorized and described in English - for instance rather than try
   to implement a fuzzy search for the code, you actually provide a
   user friendly categorization drill down; so the user works down a
   tree of specific natural language descriptions - which internally
   builds the code '10FTH86RSK'

On Apr 25, 2018, at 5:13 PM, [email protected] <mailto:[email protected]> wrote:

Hello everyone!

Currently I am working on Django.

I defined a 'Search' function in views.py:

def search(request):
     q = request.GET.get("q")
     if q:
         ReactResul = Reactionsmeta.objects.filter(id__contains=q)
         MetaResul = Metabolites.objects.filter(id__contains=q)
         GeneResul = Genes.objects.filter(id__contains=q)

     else:
             # you may want to return Customer.objects.none() instead 
ReactResul= Reactionsmeta.objects.all()
         GeneResul = Genes.objects.all()
         MetaResul = Metabolites.objects.all()
     context =dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = 
GeneResul)
     return render(request, "Recon/search.html", context)

And now I want to make it more powerful.

If I want to search '10FTH86RSK' but I cannot remember the whole name, I can just use part of the string to make query. For example, if I type '10FTK', '10FTH86RSK' should be returned as result. In that case, '10FTK', '10F6TK' or '10FTK4' should also be returned as results.

So how could I achieve this function?
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/793b8999-cac4-4c2d-94cc-eabb80f4e702%40googlegroups.com <https://groups.google.com/d/msgid/django-users/793b8999-cac4-4c2d-94cc-eabb80f4e702%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9EC3A76F-EE60-47DC-B4DD-9092D8321EC1%40gmail.com <https://groups.google.com/d/msgid/django-users/9EC3A76F-EE60-47DC-B4DD-9092D8321EC1%40gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *[email protected]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e24ffcd-a098-14f7-db47-d235fdb65002%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to