I think I have a terrible problem...

65 views
Skip to first unread message

한민수

unread,
Sep 5, 2016, 7:24:37 AM9/5/16
to django-watson discussion group
is django-watson can not search korean words...??

please... tell me "django-watson can search korean words"...

my projects has ItemPost model

for i in ItemPost.objects.all()

    print(i.title)

``````````````
"책 팔아요"
"두번째 포스트입니다" 
"내 이름은 민수입니다"
"hello world"


I follow tutorial watson wiki,

and I command in python shell

first, watson.filter(ItemPost, 'hello')
-> [<ItemPost: hello world>]

second, watson.filter(ItemPost, 'he')
-> [<ItemPost: hello world>]

it's ok...

but when I insert korean word,,

watson.filter(ItemPost, '포스트')
-> []
Oh,,,, my god!!!

the word '포스트' is second object in ItemPost named "두번째 포스트입니다"

please help me...

Jirka Vejrazka

unread,
Sep 5, 2016, 9:00:09 AM9/5/16
to 한민수
Hi, 

 I'm no expert on asian languages, but first thing to check is that your database is set correctly (collation etc.) and do some test searches directly in the database. Watson is a relatively thin wraper around DB fulltext search functionality.

 HTH

   Jirka
--
You received this message because you are subscribed to the Google Groups "django-watson discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-watso...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-watson.
For more options, visit https://groups.google.com/d/optout.

Dave Hall

unread,
Sep 5, 2016, 11:11:31 AM9/5/16
to 한민수
You can configure django-watson to use various languages when using postgres. For other databases, I'm not so sure.

from watson.backends import PostgresSearchBackend

class KoreanSearchBackend(PostgresSearchBackend):

    search_config = "pg_catalog.english"

Then, in your settings file:

WATSON_BACKEND = "your_project.KoreanSearchBackend"

You can see the list of search configs your database supports by entering \dF in the psql terminal.

My installation doesn't have a korean search config, and I'm not sure if there's one available from somewhere.

한민수

unread,
Sep 5, 2016, 11:19:57 AM9/5/16
to django-watson discussion group
@Jirka vejrazka

Thanks about your kind advice!

I have test about korean language

watson can search first word like ("두번째 포스트입니다" -> search word "두번째" O)
but can't search other word like ("두번째 포스트입니다" -> search word "입니다" X)


Message has been deleted

한민수

unread,
Sep 6, 2016, 1:42:03 AM9/6/16
to django-watson discussion group
thank you Dave Hall!

I'm using django sqlite3 now and i see watson wiki about support database,(https://github.com/etianen/django-watson/wiki/database-support)

so i will use Postgresql, thank you very much!

2016년 9월 6일 화요일 오전 12시 11분 31초 UTC+9, Dave Hall 님의 말:
Message has been deleted

한민수

unread,
Sep 6, 2016, 4:36:29 AM9/6/16
to django-watson discussion group

um.....

Hi Dave Hall

I want to search booklist names in post

class ItemPost(models.Model):

    user = models.ForeignKey(
            settings.AUTH_USER_MODEL,
            )
    title = models.TextField()

class BookList(models.Model):
    # post + booknumber => primarykey로 쓰인다

    post = models.ForeignKey(
            "ItemPost",
            )

    booknumber = models.IntegerField(
            )

    bookname = models.CharField(
            max_length=200,
            )


I can find this google groups how to search relate model
from django.apps import AppConfig
from watson import search as watson

class ItemsAppConfig(AppConfig):

    name = "items"

    def ready(self):
        ItemModel = self.get_model("ItemPost")
        watson.register(ItemModel, fields=["title","booklist_set__bookname",])

and I can find the post using title field
but booklist_set__bookname
dosen't working

and I found it has reverse...model... ummm.. (I don't know well)

anyways,

I insert `def get_booklist_set(self)` code in `ItemPost`model ( it is your advice)

In ItemPostClass

 def get_booklist_set(self):
        # Return booklist queryset directly to avoid confusing django-watson.
        return self.booklist_set.all()

and modify code

 watson.register(ItemModel, fields=["title","get_booklist_set__bookname",])

I searching bookname ... but it doesn't working too

ex)
post name : It is Post
booknames :  book1, book2, book3,,....

result_val = waton.filter(PostItem, "book")
print(result_val)
[]

Can you some advice for me please...?

Dave Hall

unread,
Sep 7, 2016, 4:51:23 AM9/7/16
to django-watson discussion group
Whenever you update the search configuration, you have to run ./manage.py buildwatson to update the search indices. Have you done that?

--
Reply all
Reply to author
Forward
0 new messages