djorm-ext-pgfulltext icon indicating copy to clipboard operation
djorm-ext-pgfulltext copied to clipboard

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

Open wengole opened this issue 10 years ago • 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.

wengole avatar May 15 '15 07:05 wengole

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

it seems to work for me @wengole

karabijavad avatar Dec 09 '15 05:12 karabijavad

+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
    )

LennyLip avatar Feb 18 '16 06:02 LennyLip