Questions tagged [ltree]

`ltree` is a PostgreSQL extension for representing labels of data stored in a hierarchical tree-like structure. Extensive facilities for searching through label trees are provided.

The ltree bundled extension for PostgreSQL is a contrib module that ships as part of PostgreSQL. It defines an ltree data type to add functionality for representing labels of data stored in a hierarchical tree-like structure. Extensive facilities for searching through label trees are provided.

ltree is loaded with CREATE EXTENSION. See the documentation linked above for details on usage.

For more information see .

101 questions
0
votes
1 answer

ltree concatenation fail when using fields but succeed when using literals

with a very simple table like this create table matpath ( obj varchar primary key, path ltree ); I'm trying to get run the following query : select path || obj from matpath; but it doesn't work, I get syntax error at position 8 It works if…
BlueMagma
  • 2,392
  • 1
  • 22
  • 46
0
votes
1 answer

Getting the children, grand children in hierarchical structure

I am working with hierarchical data model with rails and gem called ltree_hierarchy(https://github.com/cfabianski/ltree_hierarchy). In that each node will have a parent id(which is an immediate parent of the current node). 1 2 …
Aarthi
  • 1,451
  • 15
  • 39
0
votes
2 answers

hibernate with ltree native named query

I am trying to run PostgreSQL native query that contains ltree functions and operators. Here's the definition: @NamedNativeQuery( name = "pathSegmentQuery", query = "select ltree2text(okm_path) as okm_path, " + …
greengold
  • 1,184
  • 3
  • 18
  • 43
0
votes
3 answers

Laravel + PostgreSQL Ltree

How to write the migration file to add the field type 'ltree' (PostgreSQL) Schema::create('table', function (Blueprint $table) { .... $table->ltree('path'); } Does not work. Thanks!
Ilya Yaremchuk
  • 2,007
  • 2
  • 19
  • 36
0
votes
0 answers

How to do a second query with the results of a first query and aggregate those results?

I have the following set of data using the postgres ltree plugin to model a tree data structure: This query allows me to cut the tree returning nodes below the cut: with data(path) as (SELECT * FROM test WHERE yaxis >= 2 ORDER BY yaxis) select *…
JZ.
  • 21,147
  • 32
  • 115
  • 192
0
votes
1 answer

Spring Data JPA + Hibernate + Postgresql LTree. Is it possible to load whole subtree by given node with one query?

I'm using Spring Data JPA + Postgresql and I have entity "Category" which implements Postgresql LTree type and looks like this : @Id @SequenceGenerator(name = "categories_id_seq", sequenceName = "categories_id_seq", allocationSize =…
MoOFueL
  • 85
  • 12
0
votes
1 answer

Mathing all branch of a ltree in postgres

I have a tree like this: Country | State ____|____ / \ City_1 City_2 ______|______ / \ Neighborhood_1 Neighborhood_2 In…
Javier Seixas
  • 319
  • 3
  • 11
0
votes
1 answer

Postgres ltree in hibernate query

I use Play Framework 1.2.5.3 and PostgreSQL 9.x. I have class WorkArea as db model with field @Column(columnDefinition = "ltree", insertable = false, updatable = false) public String tree; In the postgre it is a database table workareas with field…
Artem
  • 505
  • 5
  • 22
0
votes
2 answers

Postgres - Counting children in level (below) using ltree

I have a table CREATE TABLE foo (text name, path ltree); A couple of inserts INSERT INTO foo (name, path) VALUES ( 'Alice', 'ROOT.first.parent'); INSERT INTO foo (name, path) VALUES ( 'Bob', 'ROOT.second.parent'); INSERT INTO foo (name, path)…
Ove Sundberg
  • 333
  • 3
  • 10
-1
votes
1 answer

Search if a value exists in postgresql ltree

I am trying to check if a particular value exists in a list of ltree column. For example path column contains values {1.2.270, 1.270.3, 1.302.270.70}. I am trying to find if the value 270 exists in any of these 3 paths. But it is not working if I am…
Klaus
  • 59
  • 1
  • 5
-1
votes
1 answer

Filter by all parts of a LTREE-Field

Let's say I have a Table people with the following columns: name/string, mothers_hierachy/ltree "josef", "maria.jenny.lisa" How do I find all mothers of Josef in the people Table? I'm searching for such a expression like this one: (That actually…
John Smith
  • 6,105
  • 16
  • 58
  • 109
1 2 3 4 5 6
7