1

I've got a table with columns of text that I'd like to search by word, not lexeme. More to the point, that I'd like to have indexed by word rather than lexeme. We've got error dumps with a lot of code references, which don't work well with any natural language dictionary.

Is there a way in Postgres to have FTS parse by word boundaries without resolving words to lexemes? If I have to define a list of boundary characters and a catalog of skip words, that could be fine. Does this require crafting some kind of custom dictionary, or is there something already like this available?

I keep thinking I'm missing something obvious, and then not finding it.

For the minute, trigram indexes are okay, but I would really prefer what amounts to a unique keyword parser for the text.

Postgres 11.4 on RDS.

  • Right you are, I've moved my comment to make it clearer. – Morris de Oryx Oct 16 at 21:06
3

Just use the simple text search configuration, which works with the simple dictionary and does not do any stemming:

CREATE INDEX ON tbl USING GIN (to_tsvector('simple', data));

And query accordingly:

SELECT *
FROM   tbl
WHERE  to_tsvector('simple', data) @@ to_tsquery('simple', 'foo');

Related:

  • Fantastic! I was missing something obvious. I've just used your clear and simple instructions and, yeah, it's great. Very fast, very easy to use. – Morris de Oryx Oct 16 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.