How to rebuild index or how to create result.url ?

77 views
Skip to first unread message

Ilya

unread,
Mar 14, 2016, 12:03:48 PM3/14/16
to django-watson discussion group
Hello, 

I have another question.
I have noticed that my watson index id  is not correlating exactly one to one to my model id value.

 
If in the table i have 34 records in the index I have 36 .(I am not aware for a reason it is possible that I have caused it and it is not the issue)

However when I am linking from my search results using the result.ID it messes up what record to open since the ID is coming from the index.

This is the template where I generate the link:
<article>
    <h1>
     XXX<a href="{% url 'company_details' pk=result.id %}"> {{result.title}}</a>
    </h1>
    {% if result.description %}
        {{result.description|linebreaks}}
    {% endif %}
</article>

So I have 2 options or to fix my index:
1-I have tried to rebuild the index with buildwatson but it is not solving the problem -so I do not know what is the way to rebuild the index then and if it is supposed to have one to one relation with model id.

2-I am not confident that I can actually correlate to result.id as for my id from the model so may be I should change my strategy and use the result.url provided by watson , but where do I build this result URL(currently is always empty)?

My goal is  that in that in every model specific template I will define diffrent link -this way in my app I am searching in 2 diffrent models but results displayed will allow to click and link to specific  view. (In my case it is company and contact)

Thanks, Ilya

Dave Hall

unread,
Mar 15, 2016, 7:03:41 AM3/15/16
to django-watson discussion group
result.url is generated from the get_absolute_url method on the model. So implement that, and you're good to go.

Or, use result.object_id, which refers to the PK of the indexed model.

--
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.

Ilya

unread,
Mar 30, 2016, 12:08:20 PM3/30/16
to django-watson discussion group
Thanks  result.object_id, worked for me
Reply all
Reply to author
Forward
0 new messages