Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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);
share|improve this question

1 Answer 1

up vote 4 down vote accepted

You need to provide a metadata table which contains the view name and the primary key name. The documentation here explains how.

share|improve this answer
    
It was useful. Thank you! –  Maxim Eliseev Jun 20 '13 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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