Giter Club home page Giter Club logo

django-watson's Introduction

django-watson

Django CI PyPI GitHub license

django-watson is a fast multi-model full-text search plugin for Django.

It is easy to install and use, and provides high quality search results.

Features

  • Search across multiple models.
  • Order results by relevance.
  • No need to install additional third-party modules or services.
  • Fast and scaleable enough for most use cases.
  • Supports Django 2+, Python 3.6+.

Documentation

Please read the Getting Started guide for more information.

Download instructions, bug reporting and links to full documentation can be found at the main project website.

You can keep up to date with the latest announcements by joining the django-watson discussion group.

Contributing

Bug reports, bug fixes, and new features are always welcome. Please raise issues on the django-watson github repository, and submit pull requests for any new code.

You can run the test suite yourself from within a virtual environment with the following commands.

    pip install psycopg2 mysqlclient -e .
    tests/runtests.py
    tests/runtests.py -d psql
    tests/runtests.py -d mysql

More information

The django-watson project was developed by Dave Hall. You can get the code from the django-watson project site.

Dave Hall is a freelance web developer, based in Cambridge, UK. You can usually find him on the Internet in a number of different places:

django-watson's People

Contributors

alorence avatar amin-pylot avatar amureki avatar bdauvergne avatar biozz avatar cristopherh95 avatar danielquinn avatar danihodovic avatar dessibelle avatar devxplorer avatar etianen avatar fitblip avatar hell10w avatar henrikhorluck avatar jirkav avatar johnfraney avatar krukas avatar moggers87 avatar nigma avatar philippeowagner avatar ryokamiya avatar samuelcolvin avatar shybert avatar simongreenhill avatar sorokins avatar syphar avatar thedrow avatar thiagoferreiraw avatar timgates42 avatar tsufeki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-watson's Issues

including related fields of model

Hello,

this is absolutely brilliant plugin and beautiful work. Thank you!!

One question. I wanted to include a related field country of my model Crag so I have tried this:
watson.register(Crag, fields=('name', 'country__name'))

That did not work but this does:
watson.register(Crag, fields=('name', 'country'))

I suppose it takes unicode representation of Country for indexing, right? My question is If I need to be concerned about what is described in section: "Searching across related models". Specifically, if I need to include watson.middleware.SearchContextMiddleware for this to work correctly. I don't quite get the section.

Thank you once again.

EDIT: one more question. Can I also, in theory, include related fields by adding them into unicode representation of an object?

Quoted Search

Hello folks,

I tried to perform some quoted searches using the tool and perceived there seems to be some implementations of search terms in quotes. But I could not find out what is its behaviour. For example, I searched for:

  1. first_word last_word and got 60 results
  2. 'first_word last_word' and got 2000 results
  3. 'first_word' 'last_word' and got 3000 results

If I was to guess, I'd say the option number 1 would be the less restrictive and the option 2 would be the most restrictive, but the number of results proves me wrong.

So, could someone explain me how Watson's quoted search implementation works?

Cheers,

Searching different fields of the same model without the '$ python manage.py buildwatson' command

Hello guys,

I am developing a kind of a search bar with watson that allows some checkboxes to choose in which fields the database search will be performed.

Can I just specify it on the run or is it needed to tun the $ python manage.py buildwatson command again? Even if I had to build it again, wouldn't be an option, since my database is getting petty large it would consume some minutes, which is not desirable from the User's point of view.

Any hints on that?

Watson with modeltranslations, any tips?

Situation

A blog with post model (title, summary, content, date_created) using modeltranslations (en, ko, ja, zh) with default of 'en' and with i18N support. So, /en/blog/url, /ko/blog/url, /zh/blog/url, /ja/blog/url is used. Now with watson search executed, always /en/blog/url is returned

So I looked into database table

There is only one field with hard coded (indexed, of course) url of /en/blog/url and all mixed contents of English, Korean, Japanese, and Chinese contents in 'content' field.

Then I did, hoping to resolve...

Added modeltranslations, and produced 'title_ko, url_ko' and rebuild the watson, hoping to index each language title and url to the related field in the watson index database. However, no matter which language field, only default language /en/blog/url is indexed to all the languages. So I manually renamed '/en/blog/url' to '/ko/blog/url' in Korean url field and the 'title' as well, then search all work fine.

So, any advice ?

I think so long as each related language fields (title, url, at least) are entered into related watson fields, things will be okay. Any advice what to look into?

Default manager ignored?

It seems the default manager of a model is ignored, as always all objects are indexed and you have to manually add a filter to the register statements. Is that intended and just not documented?

Installation issue with python 2.4.

I tried install on my python 2.4 server and got a compilation error:

running install_lib
byte-compiling /usr/lib/python2.4/site-packages/watson/registration.py to registration.pyc
File "/usr/lib/python2.4/site-packages/watson/registration.py", line 274
finally:
^
SyntaxError: invalid syntax
byte-compiling /usr/lib/python2.4/site-packages/watson/tests.py to tests.pyc
File "/usr/lib/python2.4/site-packages/watson/tests.py", line 201
with watson.update_index():
^
SyntaxError: invalid syntax.

buildwatson with verbose ?

Hello guys, is that possible to activate verbose when building watson?

In other words, I would like to have some feedback to check if it is being well succeeded and in which stage it is.

Thanks in advance!

NoReverseMatch at /fib/ u"'watson" is not a registered namespace

I'm getting an error when trying to create a form template for the search.

     NoReverseMatch at /fib/

    u"'watson" is not a registered namespace

      Request Method:        GET
      Request URL:  http://127.0.0.1:8000/fib/
      Django Version:   1.4
      Exception Type:   NoReverseMatch
      Exception Value:  

   u"'watson" is not a registered namespace

    Exception Location:     C:\Python27\lib\site-packages\django\template\defaulttags.py in render, line 424
    Python Executable:  C:\Python27\python.exe
    Python Version:     2.7.3

          {% extends "base.html" %}
      {% load watson %}

        {% block content %}
       <form action="{% url 'watson:search' %}">
      <input type="text" input name="q" value="{{request.GET.q}}">
      <input type="submit" value="Go">
     </form>
   {% endblock %}

How can I get rid of this error?

./manage.py buildwatson extremely slow on 0,5 million rows

In my Postgresql db, there are around 438 972 rows that should be tracked by watson. The problem is that full index build (using the buildwatson management command) is extremely slow.

(cb)clime@vm6879 /srv/www/cb $ time ./manage.py buildwatson

Killed

real    123m22.753s

Here the process was killed probably because it reached some system limits. It had been running for more than two hours and didn't finish.

These are register commands I use:

  watson.register(Crag, fields=('normalized_name', 'country'))
  watson.register(Member.objects.all(), fields=('normalized_name', 'user', 'country'))
  watson.register(Event, fields=('normalized_name', 'country'))
  watson.register(Route, fields=('normalized_name', 'crag__name', 'crag__normalized_name'))

The majority of all objects is contained in the Route model (more than 400 000).

I would be very happy if the time could be reduced somehow.

search index & accent insensitive search

There is an interesting difference in produced indexes in a situation where I would expect them to be the same.

Unicode function of my class Crag returns attribute name.

def __unicode__(self):
       return self.name

watson.register(Crag) produces index 'ceus':3 'céüse':1A,2

Now If I register Crag with the field name I would expect the index to be the same but it is not.

watson.register(Crag, ('name',)) produces index 'céüse':1A,2

I'd like always the first variant to apply because it provides accent insensitive search.

Add ability to build index for a specific model

First and foremost, thank you for a great package! I fell in love with it instantly :)

I started facing a minor but annoying issue - as I'm converting various search functions in my existing project, I frequently need to register another existing model with a lot of data with watson. This should be followed by "buildwatson", but that always starts from scratch and already takes ages on my poor VPS :) (e.g. overnight job)

So I hacked a quick "buildwatson_for_model" management command and put it here: https://gist.github.com/JirkaV/8228749 (sorry, I can't easily create pull request in my current environment). Would you consider adding it to django-watson? May need some polishing if it's included :)

Thank you

Jirka

Searching for instances using any part of a query

First off, this is a great package and I really appreciate all the work you've done.

Is there a way to search for any instance of the search query? Such as searching for "ick" from the work "Nick" or from say parts of a phone number like "456" from "123-456-7890"?

I'm following the standard model registration using:
import watson
watson.register("Model")

and in my view:
query = request.GET.get['q']
search_results = watson.search(query)

When I run a search for "ick" I do not get any results but yet if I search for "Nic" it comes back with "Nick"

Is there a way to add wildcards to the query? Like * or % on either side of the search term?
Any help would be greatly appreciated.
--Nick

ts_headline

Hello!
How can I print headlines in templates?

Can't install watson with models registered in models.py

The installation instructions say that this is the order to add existing content:

./manage.py syncdb
./manage.py installwatson
./manage.py buildwatson

If you run syncdb and one of your models already registers itself (in models.py or similar), running the installwatson command gives this error:

$ ./manage.py syncdb --noinput
Creating tables ...
...lots of things here...
Creating table watson_searchentry
Installing custom SQL ...
Installing indexes ...
Installed 1337 object(s) from 1 fixture(s)
$ ./manage.py installwatson
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/Library/Python/2.7/site-packages/django/db/transaction.py", line 431, in inner
    return func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/watson/management/commands/installwatson.py", line 27, in handle_noargs
    backend.do_install()
  File "/Library/Python/2.7/site-packages/watson/backends.py", line 219, in do_install
    search_config = self.search_config
  File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 51, in execute
    return self.cursor.execute(sql)
django.db.utils.IntegrityError: column "search_tsv" contains null values

Because (it looks like) the column was already created by syncdb.

Running the commands in another order doesn't solve the problem - you seem to have to run syncdb and then install with no models registered, which isn't ideal.

Am I missing something obvious?

Getting sql syntax error

Hey, I am getting an error for a query generated by Django ORM. It includes django-watson.

SELECT (left(web_crag.location_index, 4)) AS "index",
       (web_crag.type) AS "type",
       COUNT("web_crag"."id") AS "count",
       SUM("web_crag"."latitude") AS "lat_sum",
       MIN("web_crag"."id") AS "min_id",
       SUM("web_crag"."longitude") AS "lng_sum"
FROM "web_crag"
WHERE ("web_crag"."id" IN
         (SELECT DISTINCT U0."crag_id"
          FROM "web_route" U0
          INNER JOIN "web_crag" U1 ON (U0."crag_id" = U1."id") , "watson_searchentry"
          WHERE ((watson_searchentry.engine_slug = 'default')
                 AND (watson_searchentry.search_tsv @@ to_tsquery('public.english_nostop', 'Per:* & aspera:* & ad:* & astra,:* & Adlitzgraben:*'))
                 AND (watson_searchentry.object_id_int = "web_route"."id")
                 AND (watson_searchentry.content_type_id = 10)
                 AND U1."type" IN (1, 2)))
       AND (left(web_crag.location_index, 1) IN ('0',  '1',  '2',  '3')))
GROUP BY (left(web_crag.location_index, 4)), (web_crag.type) LIMIT 21;

ERROR:  invalid reference to FROM-clause entry for table "web_route"
LINE 1: ...aben:*')) AND (watson_searchentry.object_id_int = "web_route...
                                                             ^
HINT:  Perhaps you meant to reference the table alias "u0".

This is part of the code that generates the query. You can see that it passes the inner query to be used for id__in lookup field of the outer query.

    @classmethod
    def get_object_markers(cls, params):
        objects = cls.get_raw_object_list(params)
        crag_params = {
            'marker_resolution': params['marker_resolution'],
            'filter_tiles': params['filter_tiles'],
            'id_in': objects.values_list('crag_id', flat=True).order_by().distinct(),
        }
        return Crag.get_object_markers(crag_params)

Watson is applied in get_raw_object_list like this:

        watson.filter(objects, search_term)

buildwatson fails in admin.autodiscover()

buildwatson fails in admin.autodiscover() for my project. Running admin.autodiscover() from the shell works fine. If I remove admin.autodiscover() from buildwatson it works fine.

I know that line has been there since f09f263, so I don't think it's watson's fault. But can you provide any insight into why admin.autodiscover() would work in every other context (runserver, shell, etc), but not in buildwatson? It seems to run into something it thinks is a circular dependency but is not.

Also, what do I lose by removing admin.autodiscover() from buildwatson?

Thanks, and otherwise I've been very impressed with this project!

Search engine can't find small words

Hello guys,

First of all, congratulations for this amazing tool, it really surprised me, thanks =)

It seems to me that among my models fields, watson can only find words that have 4 or more letters. Is that a filter anywhere that does not indexes the 3-letters-or-less words?

For example, in my MySQL there is a field containing the name 'catherine shu'. When I search for Catherine it returns the results correctly but when I search for 'shu', it does not return anything. Is that a way to specify a thorough kind of search?

Cheers

Filter across multiple model relationships?

Hi,

Just started using watson--absolutely love it, thanks for putting together such an incredible package.

I know that we're already able to search based on a model's ForeignKeys and ManyToManys by explicitly including them in the field parameter. However, is there any way to search across more than one relationship?

I tried the following:

watson.register(Author, fields=('name', 'books', 'books__publisher'))

but when I ran manage.py buildwatson, I got the following:

watson.registration.SearchAdapterError: Could not find a property called u'publisher' on either None or <watson.registration.CustomSearchAdapter object at 0x1111182d0>

Configure indexing/searching for CountryField

CountryField: https://github.com/SmileyChris/django-countries

I have a CountryField on some of my models and would like to be able to have watson return results for objects where this field matches. Currently I'm having trouble getting the field to index with watson, I think, because of the "complex" field type not serializing to JSON properly. I think.

## Model
class Actor(Person):
    origin = CountryField(blank=True, help_text="Country of origin.")
    ...
    def get_absolute_url(self):
        return reverse('actor_detail', kwargs={'slug': self.slug})

## watson config
class ActorAdapter(watson.SearchAdapter):
    "Provide description from summary field"
    def get_description(self, obj):
        return obj.summary

watson.register(Actor, ActorAdapter, store=('scope', 'aliases', 'origin'))

With the above configuration, the buildwatson management command dies when JSON encoding fails ( traceback ).

The origin field isn't a standard Text/Char field obviously, so given it's structure, I'm wondering if that presents problems for watson? If we can get a handle on the 'name' attribute, that would be the target.

>>> actor = Actor.objects.get(pk=1)
>>> actor.origin
Country(code=u'RU', flag_url='flags/{code}.gif')
>>> type(actor.origin)
django_countries.fields.Country
>>> actor.origin.code
u'RU'

The name attribute, of interest, is a lazy translation doohickey, and requires something like unicode() to return the value of interest:

>>> actor.origin.name
<django.utils.functional.__proxy__ at 0x10f712f10>
>>> type(actor.origin.name)
django.utils.functional.__proxy__
>>> unicode(actor.origin.name)
u'Russian Federation'

All of the interesting attributes and their types for actor.origin:

>>> [(attr, type(actor.origin.__getattribute__(attr))) for attr in dir(actor.origin) if not attr.startswith('_')]
[('code', unicode),
 ('country_from_ioc', function),
 ('flag', str),
 ('flag_url', str),
 ('ioc_code', str),
 ('name', django.utils.functional.__proxy__)]

Any solutions?

Implememting icontains like method in search

Hi etianen,
Django watson is an awesome project and very easy to install and use. I am satisfied with results obtained from search text. But, I have one more question. How can I use watson.search so that it search like icontains as in Django query. I have sample code here at https://gist.github.com/mesarvagya/11397728 . Consider Indexed data are "asdfg", "astapor", "asdzxc" etc. The search text given as "as" correctly returns 3 data, but I want to get those 2 data using only "sd" as search-text, but it fails. Is there any way to achieve icontains like search?

Update of FK of registered models

Hi again,

I have a model that registers a FK on the search engine. When watson is built, it gets the string under unicode correctly. However, when I change this FK model name on django's admin page, it doesn't update the entry in the watson db table.

Is there a way of doing it already coded in watson? If not, is there any method to manually modify the entry in the db?

Thanks,
Bernardo.

PS: thanks for the tool here, it's been really helpful.

restricting either search space or results sets

so I am trying to figure a way to modify watson to either restrict the search space or results.

I have a User doing a search, they are a member of a Board.
Each Board has a nested set of Sections and Pages.
Pages are foreign keyed to Sections which are foreign keyed to Boards...

Currently I search all Sections and Pages and watson dutifully returns a result_set that contains, Pages that match the query, but those pages are from Boards the User doesn't have access to...

I suppose the only way to do this is to delete them all from the result set before returning? As many users will only be a member of a single board, if I have thousands of boards....

any ideas on a strategy? thanks in advance.

NoReverseMatch at /search/ , Error in search_results template due to {% load url from future %}

Hello,

I'm getting this error:

  Reverse for 'findevent' with arguments '()' and keyword arguments '{}' not found.

This error seems to occur only in the 'search_results.html' template. I'm not getting this error in other templates. I placed watson folder in my template folder.

From my debbugging I found out that {% load url from future %} is the one causing it.

Is there any way to get rid of this? I'm using Django 1.4

ImportError force_text

I'm getting the below error in my production server when trying to rum watson command on south. I'm using django 1.4

       File "/home/eer/mmmL/local/lib/python2.7/site-packages/watson/registration.py", line 19, in <module>
       from django.utils.encoding import force_text

Trying to avoid indexing the same model twice with buildwatson

Hello guys,

I have 2 searchable models (FooModel and BarModel) and one of them has two registered search engines, as suggested by etianen in #29. The models.py configuration is as follows:

watson.register(FooModel, fields = ('field1', 'field2', 'field3',))

watson_foo_complete = SearchEngine("watson_foo_complete")
watson_foo_complete.register(FooModel, fields=('field1', 'field2', 'field3','field4',))

watson_bar = SearchEngine("watson_bar")
watson_bar.register(BarModel, fields=('name', 'outlets', 'email', 'aliases',))

The watson_foo_complete engine contains all fields of the watson default engine with the addition of field4. The thing is, FooModel is almost 100 times bigger than BarModel and indexing the same model twice (with buildwatson) is a task that's growing exponentially.

Is that a way to use the watson_searchentry url and meta_encoded columns to keep the field4 data so it is not searchable by default but only if it is specified?? The idea here is to build the model only once.

"BTW, I am using watson in a big and fast growing MySQL database and the search queries are much faster than a common search would be. The idea of indexing the model's fields altogether is really awesome. Thank you!"

buildwatson using multiple db connections?

Hi,

I've been trying out django-watson on a small subset of my data (approx 30,000 rows in db) and everything worked amazingly well, so I'm trying it on my main "production" server with the full >1,000,000 rows. (1016126 on the primary table in question)

I understand the buildwatson process will take quite a long time, potentially days going by previous comments I've seen here, but I'd like to try to speed up wherever possible - if only as an educational exercise.

On to the question:

I see from running 'top' on my db server that only a single core is in use. It's a quad core system, so it seems a shame to not be trying to take advantage of that. I assume it's because the buildwatson task is using a single DB connection? Would it be possible to batch process the build and spread it across 4 connections so PostgreSQL can be more efficient for me?

Also, if the task is stopped or killed, does it start again when re-run, or pick up where it left off?

Many thanks.

Inconsistent behaviour of full text search on different postgres versions

>>> watson.search(u"&")
*** DatabaseError: FEHLER:  Syntaxfehler in tsquery: »&:*«

("FEHLER" == error in german)

also I quite don't understand this:

>>> watson.filter(jobs, "Geophys")
[<Job: Professor in Geophysics>, <Job: Assistant or Associate Professor in Structural Geology-Active Tectonics>]
>>> watson.filter(jobs, "Geophysics")
[]

with the following (simplified) model.py file

from django.db import models
import watson

class Job(models.Model):
    title = models.CharField(max_length=80)
    job_description = models.TextField()

    def __unicode__(self):
        return "%s" % (self.title)

watson.register(Job, fields=("title", "job_description",))

Punctuation marks

Hi etianen,

I'm having an issue while searching for an article, on a project I'm working on.
The article title is: "Here Comes the Candy Crush IPO! After a $1.9 Billion Year, King Gets Ready to Go Public"
The author is: "Peter Kafka"

Both the title and author are registered to the engine. When I search for: "peter kafka king IPO", I get no results, while searching for "peter kafka king IPO!" it returns the article. It seems that watson is not ignoring the exclamation mark.

Is there any configuration I have to change to do so?

Thanks,
Bernardo.

detect postgis as valid postresql backend

my simplistic patch:

diff backends.py orig
429c429
<         if database_engine.endswith("postgresql_psycopg2") or database_engine.endswith("postgresql") or database_engine.endswith("postgis"):

---
>        if database_engine.endswith("postgresql_psycopg2") or database_engine.endswith("postgresql"):

as you said, maybe best to check connection.vendor:

>>> print settings.DATABASES
{'default': {'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'mark1', 'HOST': '', 'USER':'', 'PASSWORD': '', 'PORT': ''}}
>>> print connection.vendor
postgresql

Documentation about search term syntax / support for boolean operators

I understand that this depends on the database backend, but could not find any explanations in the documentation/wiki.

I've skimmed the code, and it appears to be that all search terms are ANDed, after any (backend specific) special chars have been removed (via make_escaper, which I would have expected to escape them).

Do you think it would make sense to provide support for boolean operators?

I've given it a shot, but it makes it more likely / possible to get a ProgrammingError: syntax error in tsquery, that would have to get handled - maybe by falling back to the current non-magical behavior?

My naive approach allows for "NOT" and "OR":

clean_postgres_query_chars = make_escaper("():|!&*")
def escape_postgres_query_chars(text):
    text = clean_postgres_query_chars(text)
    return re.sub(r'(?i)\s+NOT\s+', '!', re.sub(r'(?i)\s+OR\s+', '|', text))

(ref: https://github.com/etianen/django-watson/blob/master/src/watson/backends.py#L156)

It's probably easy to have specialized backends (e.g. allowing some users to use the full syntax), but basic boolean operators would be nice to have shipped - even when not used by default.

PostgreSQL ref: http://www.postgresql.org/docs/9.3/static/datatype-textsearch.html#DATATYPE-TSQUERY

watson removes apostrophes from search term

It seems that single apostrophes are removed from a search term before sending the query to db. Because of that names like "Montagne d'Argent" are not found when searching for "d'Argent".

Django 1.7

Hi, project looks really useful.

Does it work with Django 1.7? If not do you have rough idea of when it will be working?

Retrieving ordered results (order_by)

Hello guys,

Is that possible to retrieve results from the watson search that are already ordered by a given attribute? For example, I'd like to retrieve the Publication model always ordered by date and the Writer model always ordered by name.

Is it possible to define the order in the register step?

I am trying to order the results, unsuccessfully, in the following way:
watson.search("Search terms", models=(Writer.objects.filter(name="foo").order_by("name",))

Is there a built in way to order the results? If this is a feature that needs to be implemented, Could you give me the guidelines?

Cheers,

Search Template shows no result.

Hello there.

I completed installing and building the search items using watson. Pretty easy to setup and use. I tried searching for a query through shell, which works fine.

I got a problem in using it in the template though. When I use it in template as you have suggested in the WiKi, it gives no result. The "search_results" count is always zero for every query string. The same query string gives result using the shell.

I also implemented my own view and template, but all in vain.

Is it a known issue? Please help me get through it.

Regards.

Syntaxfehler in tsquery: »'":*«

Another small issue during search

>>> watson.search(u'\'":*')
*** DatabaseError: FEHLER:  Syntaxfehler in tsquery: »'":*«

Currently I bypass this issue by removing the single quotes from the search term.

Wild UnicodeDecodeError will appear when building watson

Hello guys,

I have updated my database tables from a MySQL dump and I'm trying to buildwatson again. However, a wild UnicodeDecodeError rises every time I run that command and it hasn't been a easy task to debug it.

I am not sure if I have been encoding my input fields correctly. But either way, how could I debug it to check which MySQL table/row is raising this exception?

Error:

Marcelos-MacBook-Pro:prm marcelosalloum$ python manage.py buildwatson
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/db/transaction.py", line 399, in inner
    return func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/watson/management/commands/buildwatson.py", line 50, in handle_noargs
    _bulk_save_search_entries(iter_search_entries())
  File "/Library/Python/2.7/site-packages/watson/registration.py", line 168, in _bulk_save_search_entries
    search_entry_batch = list(islice(search_entries, 0, batch_size))
  File "/Library/Python/2.7/site-packages/watson/management/commands/buildwatson.py", line 34, in iter_search_entries
    for search_entry in search_engine._update_obj_index_iter(obj):
  File "/Library/Python/2.7/site-packages/watson/registration.py", line 416, in _update_obj_index_iter
    "content": adapter.get_content(obj),
  File "/Library/Python/2.7/site-packages/watson/registration.py", line 122, in get_content
    for field_name in field_names
  File "/Library/Python/2.7/site-packages/watson/registration.py", line 122, in <genexpr>
    for field_name in field_names
  File "/Library/Python/2.7/site-packages/watson/registration.py", line 65, in _resolve_field
    search_adapter = self,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 15: ordinal not in range(128)```

Issue with searching existing data

I just integrated django-watson with my database that has existing data. Search did not return any result for existing data. When I search for newly added data it works but I want it to work for data that existed before installation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.