linuxlewis/djorm-ext-pgfulltext

Any reason model methods/properties can't be indexed?

Opened this issue · 2 comments

Thanks for this package, it's very helpful.

I have some models that have very few actual fields (that store raw data) and a bunch of properties that parse the raw field into more useful output.

I'd like to be able to add the value of these properties to the search index, but from reading the code, that doesn't seem possible? Is there any reason for this?

I'm willing to contribute a pull request if you think it could be done.

you can actually just set
my_object.search_index = "abc def ghji"
then
my_object.save()

it seems to work for me @wengole

+1
It wiil be cool. Like a:

class Page(models.Model):
    name = models.CharField(max_length=200)
    description = models.TextField()
    tree = models.ForeignKey(OtherTree)

    search_index = VectorField()

    @property
    def denorm_tree(self):
         chldstr=""
         for children in tree.get_children():
            chldstr+=children.name
         return chldstr

    objects = SearchManager(
        fields = ('name', 'description'),
        customs_strings = ('denorm_tree'),
        config = 'pg_catalog.english', # this is default
        search_field = 'search_index', # this is default
        auto_update_search_field = True
    )