sinequa / sba-angular

Sinequa's Angular-based Search Based Application (SBA) Framework
https://sinequa.github.io/sba-angular/
MIT License
30 stars 23 forks source link

Breadcrumbs parsing issue #108

Closed Guillaume-Developer closed 1 year ago

Guillaume-Developer commented 1 year ago

I noticed a problem in the parsing of the breadcrumbs in the latest version where the separator is surrounded by apostrophes. For example, a filter on the term Death from the facet Meddra will give me the following breadcrumb display: MedDra': 'Death.

While digging through the code to find the source of this display error, I realized that it might be a global issue on the processFormatMessage(message: string, values = {}) function in core\intl\intl.service.ts. The html produced by the function looks like this <span class="sq-field">MedDra</span>'<span class="sq-separator">: </span>'<span class="sq-value">Death</span> and the value passed to the formatter looks like this '<span class="sq-field">'{value0}'</span>''<span class="sq-separator">'{value1}'</span>''<span class="sq-value">'{value2}'</span>'. So, looking at these, it feels like the double single-quotes are not treated correctly by the formatter, and one of the two quotes is not being deleted in the final message.

ericleib commented 1 year ago

How can I reproduce this? Does this happen when you click on a facet ? What is the raw data coming from the server for this metadata ?

ericleib commented 1 year ago

By the way in the latest development versions, we got rid of a lot of things, including the fielded search syntax, the "expressions", breadcrumbs, etc. This is replaced by new components and a change in the query web service, making everything much simpler.

Guillaume-Developer commented 1 year ago

These new development versions have yet to be made public right? I looked at the vanilla-search project and I'm seeing it uses a new facet component for displaying the breadcrumbs, but it still uses the breadcrumbs though.

My issue can be reproduced by using the sqExpr pipe on the display value of a breadcrumb item (if it is an Expr type), created from a left side filter, and using the withFields: true and asHTML: true. My query looks like this: query=%7B"name":"query","text":"cancer","tab":"all","select":%5B%5B"treepath:%20(%60Website%60:%60%2FWebsite%2F*%60)","treepath"%5D%5D%7D

ericleib commented 1 year ago

Yes, the version I am talking about is not on Github, but it is available in the nightly builds of the product (on download.sinequa.com).

Your sample query doesn't have the "Meddra: Death" filter, so I assume the problem occurs with any metadata, including the treepath?

Guillaume-Developer commented 1 year ago

Alright, I will have a look when I have the time then.

Sorry, I gave you the wrong query, here's the one with "Meddra: Death". query=%7B"name":"query","text":"cancer","tab":"all","select":%5B%5B"entity22:%20(%60Death%60:%60DEATH%60)","meddra"%5D%5D%7D

It occurs with both tree type or list filters. I did not test out the tag-cloud filters.

When debugging with console.log I could pinpoint the fact that the function processFormatMessage(message: string, values = {}) received the values message = '<span class="sq-field">{value0}</span><span class="sq-separator">{value1}</span><span class="sq-value">{value2}</span>' and values = { value0 = 'Meddra', value1 = ': ', value2 = 'Death' }. Then, you are adding single quotes around the html tags and then feed the transformed html to the function formatters.getMessageFormat(...). The transformed html looks like this '<span class="sq-field">'{value0}'</span>''<span class="sq-separator">'{value1}'</span>''<span class="sq-value">'{value2}'</span>', but then the final result returned by this function looks like this <span class="sq-field">MedDra</span>'<span class="sq-separator">: </span>'<span class="sq-value">Death</span>. Where the transformed html contained double single-quotes, the final results now contains single-quotes.

ericleib commented 1 year ago

FYI @Guillaume-Developer I finally took some time to fix this issue, cf the opened PR.