Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need to combine two OCG filters. each one works fine separably but if i combine them using Filter.Logical.OR, the first one works only.

var c_filter = new OpenLayers.Filter.Logical({ 
type: OpenLayers.Filter.Logical.OR, 
filters: [ 
new OpenLayers.Filter.Comparison({ 
    type: OpenLayers.Filter.Comparison.EQUAL_TO, 
    matchCase:false, 
    property: 'id', 
    value:(document.getElementById("Text")).value     
    }),   
new OpenLayers.Filter.Comparison({ 
    type: OpenLayers.Filter.Comparison.LIKE, 
    matchCase:false, 
    property: 'name', 
    value: "*" +(document.getElementById("Text")).value + "*"   
    })  
    ] 
}); 

as you can see, the first one expect integer and the other one a string. also i tried:

var id_filter = new OpenLayers.Filter.Comparison({ 
    type: OpenLayers.Filter.Comparison.EQUAL_TO, 
    matchCase:false, 
    property: 'id', 
    value:(document.getElementById("searchText")).value     
    });   
var name_filter = new OpenLayers.Filter.Comparison({ 
    type: OpenLayers.Filter.Comparison.LIKE, 
    matchCase:false, 
    property: 'name', 
    value: "*" +(document.getElementById("searchText")).value + "*"   
    });     

var orFilter = new Array(); 
orFilter.push(id_filter); 
orFilter.push(name_filter); 



wfsProtocol.read({             
    filter: new OpenLayers.Filter.Logical({ 
                 type: OpenLayers.Filter.Logical.OR, 
                 filters: orFilter 
             }),        
    callback: processTheQuery, 
    scope: strategy 
         }) 

and still, the id_filter works fine. but the name_filter i got the error: ERROR: invalid input syntax for integer: "test name" i don't understand why it should be integer !! and if i try name_filter alone, it works fine !

share|improve this question
    
What about if you add the name_filter in array before the id_filter, do you get the same message ? – Shady Mar 24 at 6:50

Try to replace

value: "*" +(document.getElementById("searchText")).value + "*"

with

value: "%" +(document.getElementById("searchText")).value + "%"

I think you are using wrong wildcards, thats the problem

EDIT

Oops, also try to remove the extra ()

Try this

value: "%" +document.getElementById("searchText").value + "%"

share|improve this answer

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.