Select to view content in your preferred language

Enhanced search widget sql queries

2114
5
02-03-2011 02:09 PM
LisaArnold
Deactivated User
I am working with the enhanced search widget, compiled version 2.2.6 in FlexViewer 2.1 I am having trouble with entering SQL query statements in the text box. If anybody is willing to help me trouble shoot I would sure appreciate it. I had originally been using 2.2.4, but upgraded for good measure. The same issues exist.

http://gis-web.heritage.unm.edu/gpd/


I have been testing with the layer Field Validation and the field FieldYr. If I enter just one year, I get the appropriate search results. When I enter a SQL statement, I get more data than what I asked for. For exmple: FieldYr &gt:= 2003 AND FieldYr &lt:= 2005 returns points with FieldYr ranging from 1978-2010 as does the statement: FieldYr &gt: 200.

Putting in an OR query, FieldYr = 1978 OR FieldYr = 2003 generates an "Unable to complete operation" error.

An additional problem is that I know my escaped characters are supposed to use a ; however using a ; generates an "unable to complete operation" error. Using a : at least does a search, but returns the wrong results.

I have attached a .txt version of my search widget xml configuration file here. Thanks for any idea on resolving these issues.

Lisa Arnold
University of New Mexico
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   The User Interface has no way currently to handle querying based on two different values like you are attempting. There is a simple no code change work around for what you are trying though:

            <expressions>
             <expression alias="PhotoYr" textsearchlabel="Search Photo Year [ Example: 2003 ]:">PhotoYr = [value]</expression>
             <expression alias="FieldYr" textsearchlabel="Search Field Year [ Example: 2003 ]:">FieldYr = [value]</expression>
             <expression alias="FieldYr between 2003 and 2005 Range" textsearchlabel=" Type: FieldYr &gt;= 2003 AND FieldYr &lt;= 2005">[value]</expression>
             <expression alias="FieldYr 1978 or 2003" textsearchlabel="Type: FieldYr = 1978 OR FieldYr = 2003">[value]</expression>
            </expressions>


Notice the last two expressions... If the user follows the prompt then the query will succeed. Note the
&gt;
can be entered as a normal > symbol by the user into the input box.
Let me know if any of this is unclear.
0 Kudos
LisaArnold
Deactivated User
Ah ok I think I understand now. So these two lines:
<expression alias="FieldYr between 2003 and 2005 Range" textsearchlabel=" Type: FieldYr &gt;= 2003 AND FieldYr &lt;= 2005">[value]</expression>
             <expression alias="FieldYr 1978 or 2003" textsearchlabel="Type: FieldYr = 1978 OR FieldYr = 2003">[value]</expression>


actually enable the user to enter any range search or OR query, really any SQL query statement on one field. So I think then I could do something like just the one expression below to meet my needs.

<expression alias="FieldYr Advanced Query" textsearchlabel="Enter SQL query, refer to documentation for examples">[value]</expression


I tested this out and it is working how I expect. Thank you very much for explaining this to me!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   I'm glad that you got it working. I would constantly check the code gallery as I am enhancing and fixing bugs on my widgets all the time. I am about to release a new version (hopefully today) of this Enhanced Search Widget that addresses some symbology issues and introduces a resizable datagrid. So I recommend you always keep up to date on the current version of my widgets.
0 Kudos
LisaArnold
Deactivated User
Robert,

Will do, looking forward to the new version. Just to make sure... in general when I change to a new version of a widget I should be able to basically replace the specific widget folder (ie. eSearch) in my widgets folder, and then replace the xml config file in that file with my old xml file (ie SearchWidget.xml).

I know in some instances I may have to redo my xml file if there are big changes, but in general is the recommended process? I know this version of the eSearch also includes the assets folder inside of it now.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Lisa,

   Yep, that is the best way.
0 Kudos