[Geomoose-users] GeoMoose 3 - Search
Christopher Hughes
chughes at co.lincoln.or.us
Thu Mar 19 08:09:24 PDT 2020
Thanks Dan!
I'll try this when I get a chance and put together a doc assuming I get it
working.
Chris
On Wed, Mar 18, 2020 at 7:55 PM Dan Little <theduckylittle at gmail.com> wrote:
> Ack! It was very close. Note the "[query]" in the return. It's expecting
> the OR statements to be wrapped like: "['or', ... field 1 ... , ... field
> 2...]":
>
> prepareFields: function (fields) {
> // reformat the fields for the query engine,
> // "*stuff*" will do a case-ignored "contains" query.
> var query = ['or'];
> for(var i = 0, ii = fields.length; i < ii; i++) {
> if(fields[i].value !== '' && fields[i].value !==
> undefined) {
> query.push({
> comparitor: 'ilike',
> name: fields[i].name,
> value: '%' + fields[i].value + '%'
> });
> }
> }
> return [query];
> }
>
> See the Gist here:
> https://gist.github.com/theduckylittle/c659413dc4fdcbcd793bd2148202332f
>
> On Tue, Feb 11, 2020 at 6:28 PM Christopher Hughes <
> chughes at co.lincoln.or.us> wrote:
>
>> Hi Dan,
>>
>> I'm having trouble getting this working. I've tried several combinations
>> of the code below. When I omit the fields parameter at the end there's no
>> box to input a search,
>> but with it I'm unsure about how to adjust it for searching multiple
>> fields. Depending on how what I try I either get a comparitor error or an
>> error saying prepareFields/queryFields
>> isn't defined. Do you have any ideas?
>>
>> Working in the demo:
>> app.registerService('search', SearchService, {
>>
>> prepareFields: function(fields) {
>> var query = ['or']; // adding or to the beginning should make it
>> conditional.
>> var queryFields = ['OWNER_NAME', 'OWN_ADD_L1', 'OWN_ADD_L3'];
>> var searchValue = fields[0].value;
>> for(var i = 0, ii = queryFields.length; i < ii; i++) {
>> query.push({
>> comparitor: 'ilike',
>> name:queryFields[i],
>> value: '%' + searchValue + '%'
>> });
>> }
>> return query;
>> },
>> fields: [
>> {type: 'text', label: 'City/State/ZIP', name: 'prepareFields'}
>> ],
>> searchLayers: ['vector-parcels/parcels']
>>
>>
>> });
>>
>>
>> Thanks,
>> Chris
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thu, Feb 6, 2020 at 3:07 PM Dan Little <theduckylittle at gmail.com>
>> wrote:
>>
>>> Pass it in as an option on app.js.
>>>
>>> On Thu, Feb 6, 2020, 18:04 Christopher Hughes <chughes at co.lincoln.or.us>
>>> wrote:
>>>
>>>> Hi Dan,
>>>>
>>>> Do you mean changing this in the search.js file or trying to overwrite
>>>> this in app.js when creating the individual search service?
>>>>
>>>> Thanks,
>>>>
>>>> Chris
>>>>
>>>> On Wed, Feb 5, 2020 at 6:42 AM Dan Little <theduckylittle at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Chirs,
>>>>>
>>>>> You can make that happen by overriding "prepareFields" in the options.
>>>>>
>>>>> This is a little rough and untested but I believe this would do it:
>>>>>
>>>>> prepareFields: function(fields) {
>>>>> var query = ['or']; // adding or to the beginning should make
>>>>> it conditional.
>>>>> var queryFields = ['PIN', 'NAME', 'STREETNAME'];
>>>>> var searchValue = fields[0].value;
>>>>> for(var i = 0, ii = queryFields.length; i < ii; i++) {
>>>>> query.push({
>>>>> comparitor: 'ilike',
>>>>> name:queryFields[i],
>>>>> value: '%' + searchValue + '%'
>>>>> });
>>>>> }
>>>>> return query;
>>>>> };
>>>>>
>>>>> On Tue, Feb 4, 2020 at 3:33 PM Christopher Hughes <
>>>>> chughes at co.lincoln.or.us> wrote:
>>>>>
>>>>>> Does anyone know if there's a way to configure a search service in
>>>>>> geomoose 3 that searches
>>>>>> over multiple fields in a single box?
>>>>>>
>>>>>> I'd like to be able to configure a simple search that allows users to
>>>>>> enter information in a single box
>>>>>> and find results that match information in any of the fields you
>>>>>> specify. This way they don't need to
>>>>>> know as much about how your data is organized. My current workaround
>>>>>> is to just create a new
>>>>>> dataset that has all the fields I want, concatenated into a single
>>>>>> field, and set geomoose to search
>>>>>> that in the service. This gets the job done but I'd rather not modify
>>>>>> the data if I don't have to.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Chris
>>>>>>
>>>>>> --
>>>>>> Chris Hughes
>>>>>>
>>>>>> GIS Analyst
>>>>>> Lincoln County Surveyor Department
>>>>>> 880 NE 7th St. l Newport, OR 97365
>>>>>> Tel: (541) 574 1283
>>>>>> _______________________________________________
>>>>>> Geomoose-users mailing list
>>>>>> Geomoose-users at lists.osgeo.org
>>>>>> https://lists.osgeo.org/mailman/listinfo/geomoose-users
>>>>>
>>>>>
>>>>
>>>> --
>>>> Chris Hughes
>>>>
>>>> GIS Analyst
>>>> Lincoln County Surveyor Department
>>>> 880 NE 7th St. l Newport, OR 97365
>>>> Tel: (541) 574 1283
>>>>
>>>
>>
>> --
>> Chris Hughes
>>
>> GIS Analyst
>> Lincoln County Surveyor Department
>> 880 NE 7th St. l Newport, OR 97365
>> Tel: (541) 574 1283
>>
>
--
Chris Hughes
GIS Analyst
Lincoln County Surveyor Department
880 NE 7th St. l Newport, OR 97365
Tel: (541) 574 1283
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geomoose-users/attachments/20200319/02c50904/attachment-0001.html>
More information about the Geomoose-users
mailing list