Lets say I have a book represented like this:
{ title: "Tis no book"
chapter: 1,
text: "Hello world this is a book chapter",
subchapters: [
{
chapter: 1.1
text: "Nested sub chapter"
subchapters: [
chapter: 1.1.1
text: "Nested nested..."
subchapters: [ ...etc...]
},
{
chapter: 1.2
text: "Nested sub chapter 2"
subchapters: [ ...etc...]
}
]
}
Can I use postgres' 9.4 new jsonb/gin (or anything else) to set up a full text index on the "text"
field of this recursively nested data structure such that a library of books stored to the database can be searched by text (using the index)?
I have just started looking into full-text search and jsonb types. It looks like this is possible once you understand how the indexes work on JSONB types. I have found this blog series to be very helpful.
https://bibhas.in/blog/postgresql-swag-part-2-indexing-json-data-type-and-full-text-search/
Also, the documentation on the JSON type at Postgres contains some good insights. http://www.postgresql.org/docs/9.4/static/datatype-json.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With