Changeset 24073 for main/trunk/greenstone2/runtime-src
- Timestamp:
- 2011-05-20T16:43:29+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp
r23635 r24073 738 738 for (int i=0; i< values.size(); ++i) { 739 739 if (!values[i].empty()) { 740 text_t this_value = values[i]; 741 742 // remove operators for simple search, segments text if necessary 743 format_querystring(this_value, argb, segment); 744 745 // add tag info for this field (and other processing) 746 format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb); 747 748 const text_t DISTINCT_SELECT_WHERE 749 = "SELECT DISTINCT docOID FROM document_metadata WHERE "; 740 text_t this_value; 741 const text_t STARTINGWITH_CONDITION = "STARTINGWITH"; 742 const text_t LIKE_CONDITION = "LIKE"; 743 744 //Change the STARTINGWITH operator to 'LIKE' and then adds '%' to the end of the value field 745 //in order to search a field starting with certain words. 746 if (sqlcombs[i] == STARTINGWITH_CONDITION) 747 {this_value = values[i]; 748 this_value += "%"; 749 // remove operators for simple search, segments text if necessary 750 format_querystring(this_value, argb, segment); 751 // add tag info for this field (and other processing) 752 format_field_info_sql(this_value, fields[i], LIKE_CONDITION, argt, argb);} 753 754 else 755 {this_value = values[i]; 756 // remove operators for simple search, segments text if necessary 757 format_querystring(this_value, argb, segment); 758 // add tag info for this field (and other processing) 759 format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);} 760 761 762 const text_t DISTINCT_SELECT_WHERE = "SELECT DISTINCT docOID FROM document_metadata WHERE "; 750 763 751 764 if (querystring.empty()) { … … 808 821 else if (combs[i-1]=="not") { combine = "NOT"; } 809 822 } 810 text_t this_value = values[i]; 811 812 // remove operators for simple search, segments text if necessary 813 format_querystring(this_value, argb, segment); 814 815 // add tag info for this field (and other processing) 816 format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb); 817 818 // add into query string 819 820 const text_t DISTINCT_SELECT_WHERE 821 = "SELECT DISTINCT docOID FROM document_metadata WHERE "; 823 text_t this_value; 824 const text_t STARTINGWITH_CONDITION = "STARTINGWITH"; 825 const text_t LIKE_CONDITION = "LIKE"; 826 827 //Change the STARTINGWITH operator to 'LIKE' and then adds '%' to the end of the value field 828 //in order to search a field starting with certain words. 829 if (sqlcombs[i] == STARTINGWITH_CONDITION) 830 {this_value = values[i]; 831 this_value += "%"; 832 // remove operators for simple search, segments text if necessary 833 format_querystring(this_value, argb, segment); 834 // add tag info for this field (and other processing) 835 format_field_info_sql(this_value, fields[i], LIKE_CONDITION, argt, argb);} 836 837 else 838 {this_value = values[i]; 839 // remove operators for simple search, segments text if necessary 840 format_querystring(this_value, argb, segment); 841 // add tag info for this field (and other processing) 842 format_field_info_sql(this_value, fields[i], sqlcombs[i], argt, argb);} 843 844 const text_t DISTINCT_SELECT_WHERE = "SELECT DISTINCT docOID FROM document_metadata WHERE "; 822 845 823 846 if (querystring.empty()) { … … 980 1003 element_in += tags_in + ") AND ("; 981 1004 1005 982 1006 if (sqlcomb == "=") { 983 1007 // override what it means to do equality, to make it more like full text … … 1025 1049 1026 1050 element_in += orterms; 1051 } 1052 //We cast the value from STRING to REAL to allow numeric sorting 1053 else if (sqlcomb == "<num") { 1054 element_in += "CAST(value as REAL) < CAST('" + querystring+"' AS REAL)"; 1055 } 1056 else if (sqlcomb == ">num") { 1057 element_in += "CAST(value as REAL) > CAST('" + querystring+"' AS REAL)"; 1058 } 1059 else if (sqlcomb == "<=num") { 1060 element_in += "CAST(value as REAL) <= CAST('" + querystring+"' AS REAL)"; 1061 } 1062 else if (sqlcomb == ">=num") { 1063 element_in += "CAST(value as REAL) >= CAST('" + querystring+"' AS REAL)"; 1064 } 1065 else if (sqlcomb == "=num") { 1066 element_in += "CAST(value as REAL) = CAST('" + querystring+"' AS REAL)"; 1027 1067 } 1028 1068 else {
Note:
See TracChangeset
for help on using the changeset viewer.