PaulP
PaulP

Reputation: 1935

Full text search in html content

I need to have full text search for html content. I have one solution but before I decide to it I want to check are there any other solutions.

I will describe on very simplified example. I have table with some data:

CREATE VIRTUAL TABLE Post USING fts3(Title, Content);
INSERT INTO post VALUES("Title 1", "Some content");
INSERT INTO post VALUES("Title 2", "<b>S</b>ome <b>C</b>ontent");

I am searching all rows which contains "Some" string for content column. Can I do this in one query? Using MATCH

SELECT * FROM post WHERE Content MATCH 'Some';

it will find first row.

My solution is to make two tables. First table will be normal (not full text search) for html content and second for plain text content with full text search on. Second table will have content from first but without html tags.

It is important to me do this within sqlite.

Upvotes: 0

Views: 395

Answers (1)

CL.
CL.

Reputation: 180290

The FTS module use tokenizers to detect words in the text.

There is no built-in tokenizer that ignores HTML tags; you would have to write a custom tokenizer. It might be a better idea use a table with plain text data.

Upvotes: 1

Related Questions