[QGIS-Developer] Fastest Way to Search Through Attributes

C Hamilton adenaculture at gmail.com
Wed Jun 16 09:18:35 PDT 2021


Back with QGIS 2 I wrote a plugin that would do a search on all attributes
and all layers (Search Layers plugin) I ported it to QGIS 3 to satisfy user
requests despite the Locator service being available. I currently have a
request to update this plugin to allow another search string with AND, OR,
NOT operations.

The questonI have is what is the fastest way to search through the
attributes? The current implementation in the Search Layers plugin when
searching all attributes is to iterate through each feature and test the
search string on a string representation of each attribute field. If there
is a match it is reported.

If I am searching a single attribute then I set up a QgsFeatureRequest and
set the filter expression and then I can just iterate through all the
features that match the expression.

With all the enhancements to QGIS, is there a better way to do these
searches? The result of the search needs to include which feature matched
and which attribute(s) matched. I am looking for the fastest method of
searching a vector layer.

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210616/f0201717/attachment.html>


More information about the QGIS-Developer mailing list