Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix searching number fields #624

Merged
merged 3 commits into from
May 4, 2018
Merged

Conversation

hwbllmnn
Copy link
Member

@hwbllmnn hwbllmnn commented May 4, 2018

FEATURE

Description:

This PR fixes searching number fields via WFS. This is still far from perfect. You can configure the WFS search now with attribute details, which allows you to control how filters are created. matchCase can be used to control the corresponding filter attribute, exactSearch will make the code check for attributes of type number and int and skip the filter completely if the search term contains non numeric characters.

We should really think about doing a solr or elastic search backend in order to get better results.

@terrestris/devs Please review.

Copy link
Member

@KaiVolland KaiVolland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice.
Just one minor change-request to be more clear about the attributeDetails.

* An object mapping feature types to an array of attribute details.
* @type {Object}
*/
attributeDetails: PropTypes.object,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make use of PropTypes.shape.
This way you can define the existing detail keys and their types.
e.g.:

// An object taking on a particular shape
  attributeDetails: PropTypes.shape({
    exactSearch: PropTypes.bool,
    type: PropTypes.oneOf(['int', 'string', 'number', ]),})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, added in 3dec246.

@KaiVolland
Copy link
Member

Nice. Didn't expect teh attribtueDetails as this complex but it looks quite strict now. 👍

So i guess the structure is something like this?:

{
  layer1: [{
    attribute1: {
      matchCase: true,
      type: 'number',
      exactSearch: false
    },
    attribute2: {
      matchCase: false,
      type: 'string',
      exactSearch: true
    },}],
  layer2: [],}

@hwbllmnn
Copy link
Member Author

hwbllmnn commented May 4, 2018

Yes, exactly. It looks quite complex, but at least it matches the structure of the searchAttributes prop and makes accessing it easy. In an ideal world we should merge those two into a new structure, I just wanted to keep backwards compatibility.

@hwbllmnn hwbllmnn merged commit 8c866b0 into terrestris:master May 4, 2018
@hwbllmnn hwbllmnn deleted the fix-number-fields branch May 4, 2018 13:54
hblitza pushed a commit that referenced this pull request Oct 19, 2022
chore: enable typescript to emit declarations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants