Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

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.