I have a layer in GeoServer. It is based on PostGis view. It seems that GeoServer generates random featureIDs. The view has the same columns as the underlying table, including the PK column. But GeoServer ignores the PK column for layers based on the view.
When I created a layers based on the table itself, Geoserver used PK as featureID.
How to make GeoServer to do the same for a view?
Thank you in advance.
UPDATE
I've accepted iant's answer. SQL I used to create the metadata table is below. After I ran it on the PostGis DB, I've restarted GeoServer and recreated the layer. It worked.
-- http://docs.geoserver.org/stable/en/user/data/database/primarykey.html#metadata-table-description
CREATE TABLE gt_pk_metadata_table (
table_schema VARCHAR(32) NOT NULL,
table_name VARCHAR(32) NOT NULL,
pk_column VARCHAR(32) NOT NULL,
pk_column_idx INTEGER,
pk_policy VARCHAR(32),
pk_sequence VARCHAR(64),
unique (table_schema, table_name, pk_column),
check (pk_policy in ('sequence', 'assigned', 'autoincrement'))
);
INSERT INTO gt_pk_metadata_table(
table_schema, table_name, pk_column, pk_column_idx, pk_policy,
pk_sequence)
VALUES (
'public',
'llsoa',
'identifier',
1,
'assigned',
null);
Answer
You need to provide a metadata table which contains the view name and the primary key name. The documentation here explains how.
No comments:
Post a Comment