<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>I think I found a bug in Xapian 1.5 when using FLAG_WORD_BREAKS for input that contains characters in Unicode Halfwidth and Fullwidth Forms (<a href="https://unicode.org/charts/PDF/UFF00.pdf">https://unicode.org/charts/PDF/UFF00.pdf</a>).<br></div><div><br></div><div>Since I am undecided yet if and how to fix this in Xapian I haven't come up with a pull request. Because trac currently is offline, I could not file a bug. I hope it's OK to post my analysis here first, I'll be happy to follow up reporting that bug proper later (should we conclude that it actually is a bug).<br></div><div><br></div><div>Imagine indexing the following Japanese text "三菱UFJファクター株式会社" which in English denotes the "<span class="js-company-name">Mitsubishi UFJ Factors Limited" bank.</span><br></div><div><br></div><div>Using word segmentation in Xapian 1.5 this causes the following terms to get indexed:<br></div><div>ファクター<br></div><div>三菱<br></div><div>株式会社<br></div><div>UFJ<br></div><div><br></div><div>Note that last term, which starts with FULLWIDTH LATIN CAPITAL LETTER U' (U+FF35). Xapian's Unicode library correctly assigns this the UPPERCASE_LETTER category and indexes this verbatim.<br></div><div><br></div><div>However, querying for UFJ produces the query Query(ufj@1). That is, it queries for the lowercase form which seems to be the result of unconditional lower-casing at <a href="https://github.com/xapian/xapian/blob/master/xapian-core/queryparser/queryparser.lemony#L1459">https://github.com/xapian/xapian/blob/master/xapian-core/queryparser/queryparser.lemony#L1459</a>. As a result, the query returns no result.<br></div><div><br></div><div>I have written code that demonstrates this at <a href="https://gist.github.com/rsto/168a61536793e10a0a07c3920977e5eb">https://gist.github.com/rsto/168a61536793e10a0a07c3920977e5eb</a><br></div><div><br></div><div>Now, I think that much of this issue can be prevented by normalizing both indexed text and queries before passing them over the Xapian, but this requires to rewrite indexes so isn't necessarily a quick fix. As a workaround, I chose to detect such queries and query for both the lower-cased and original uppercase forms in our systems.<br></div><div><br></div><div>Still, I do think it is a bug for Xapian not to return a result when querying for a term that's verbatim in the original input and the database. Should you agree I will be happy to discuss how to fix this and might come up with a pull request once we agreed on a solution.<br></div></body></html>