Improve query

Hi, I am trying to improve the quality of the query inside Ruby. This
below query is giving very long output. Can anyone please let me know if
there a way to use cache instead of retrieving them every time from the
database?

@queries.each_pair do |field_name, value_array|
if ( check_for_symbols )
force_to_symbol = []
keep_as_requested = []
value_array.each do | value |
the_symbols = get_symbol(nil, value.strip.upcase.gsub(/"/,
‘’), true)
if ( !the_symbols.nil?)
the_symbols.each { | the_symbol | force_to_symbol <<
the_symbol[:symbol]}
else
keep_as_requested << value
end
end
if ( keep_as_requested.length > 0 )
query_string << (joiner + field_name.to_s + ‘:(’ +
keep_as_requested.join(’ OR ') + ') ')
joiner = ‘OR ’
end
if ( force_to_symbol.length > 0 )
query_string << (joiner + :symbol.to_s + ‘:(’ +
force_to_symbol.join(’ OR ') + ') ‘)
end
else
query_string << (joiner + field_name.to_s + ‘:(’ +
value_array.join(’ OR ') + ') ')
end
joiner = 'OR ’
end

Here is a part of the output of the query, I am looking at improving
this part. I am stuck here, can anyone please help me how to move ahead.

content_item_id:(“181972”+OR+“165688”+OR+“206442”+OR+“210046”+OR+“212381”+OR+“218248”+OR+“237820”+OR+“319741”+OR+“326438”+OR+“372154”+OR+“414015”+OR+“414695”+OR+“414519”+OR+“414436”+OR+“422899”+OR+“444846”+OR+“447426”+OR+“447110”+OR+“447094”+OR+“404437”+OR+“485804”+OR+“485799”+OR+“485810”+OR+“485815”+OR+“485814”+OR+“485875”+OR+“485873”+OR+“485886”+OR+“485884”+OR+“485889”+OR+“485893”+OR+“485896”+OR+“485897”+OR+“485908”+OR+“485911”+OR+“485923”+OR+“461256”+OR+“492869”+OR+“527197”+OR+“403642”+OR+“694806”+OR+“694797”+OR+“766050”+OR+“326440”+OR+“326437”+OR+“237825”+OR+“767127”+OR+“849286”+OR+“890533”+OR+“890604”+OR+“1009042”+OR+“1015252”+OR+“1009900”+OR+“1016545”+OR+“1020745”+OR+“1016445”+OR+“1047557”+OR+“1009899”+OR+“1133192”+OR+“1134945”+OR+“1136568”+OR+“1132765”+OR+“947707”+OR+“1114992”+OR+“1151325”+OR+“1152561”+OR+“1172796”+OR+“1167362”+OR+“1154865”+OR+“1173326”+OR+“1173328”+OR+“1174271”+OR+“1173327”+OR+“1173329”+OR+“1175410”+OR+“1176527”+OR+“1300306”+OR+“1489970”+OR+“1525026”+OR+“1538968”+OR+“1539002”+OR+“1538958”+OR+“1538999”+OR+“1531411”+OR+“1565686”+OR+“1583721”+OR+“1608461”+OR+“730395”+OR+“685379”+OR+…

Thanks in advance.
Naina

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs