Changeset 13911
- Timestamp:
- 2007-02-14T16:29:04+13:00 (17 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/service
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2FieldSearch.java
r13574 r13911 89 89 // the default level for retrieval - and we'll use it for searching too 90 90 protected String default_level=null; 91 // the default field for searching 92 protected String default_field = null; 91 93 92 // which search services will we offer?? 94 93 protected boolean plain_search = false; … … 161 160 } 162 161 163 // set up the extra services which are available for this collection 164 // check the config info - if there is no field list, then there is no fielded searching 165 166 Element field_list = (Element) GSXML.getChildByTagName(info, GSXML.FIELD_ELEM+GSXML.LIST_MODIFIER); 167 if (field_list==null) { 168 // nothing more to do 169 return true; 170 } 171 162 172 163 // the format info is the same for all services 173 164 Element format_info = (Element)format_info_map.get(TEXT_QUERY_SERVICE); 174 175 // find the default field - use the first one 176 Element first_field = (Element)GSXML.getChildByTagName(field_list, GSXML.FIELD_ELEM); 177 default_field = first_field.getAttribute(GSXML.SHORTNAME_ATT); 178 // else set up the fielded query services 179 165 166 // set up the extra services which are available for this collection 180 167 if (this.simple_form_search) { 181 168 // set up short_service_info_ - for now just has id and type - name will be added in on the fly … … 348 335 349 336 } 350 protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang){351 // we currently only have one index, and use the field data as the index352 353 // the field list - read from config file354 Element field_list = (Element)GSXML.getChildByTagName(this.config_info, GSXML.FIELD_ELEM+GSXML.LIST_MODIFIER);355 NodeList fields = field_list.getElementsByTagName(GSXML.FIELD_ELEM);356 for (int i=0; i< fields.getLength();i++) {357 String shortname = ((Element)fields.item(i)).getAttribute(GSXML.SHORTNAME_ATT);358 String name = ((Element)fields.item(i)).getAttribute(GSXML.NAME_ATT);359 if (name.equals("")) {360 // no name, ignore361 continue;362 }363 // TODO change field so that name is the id, and full metadata name is somthing else364 if (shortname.equals("")) {365 shortname = name;366 }367 index_ids.add(shortname);368 // should these be changed to a text element based on lang?369 // or is the name of a metadata element eg dc:Title its370 // name in all langs371 index_names.add(name);372 }373 }374 375 337 376 338 // the following three functions are needed so the base class can … … 441 403 String field = (String) params.get(INDEX_PARAM); 442 404 if (field == null) { 443 field = default_ field;405 field = default_index; 444 406 } 445 407 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2Search.java
r13270 r13911 97 97 Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM); 98 98 if (def != null) { 99 this.default_index = def.getAttribute(GSXML. NAME_ATT);99 this.default_index = def.getAttribute(GSXML.SHORTNAME_ATT); 100 100 } // otherwise will be "", and the first one will be the default 101 101 … … 178 178 } 179 179 180 protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang) { 181 // the index info - 182 Element index_list = (Element)GSXML.getChildByTagName(this.config_info, INDEX_ELEM+GSXML.LIST_MODIFIER); 183 NodeList indexes = index_list.getElementsByTagName(INDEX_ELEM); 184 int len = indexes.getLength(); 185 // now add even if there is only one 186 for (int i=0; i<len; i++) { 187 Element index = (Element)indexes.item(i); 188 String shortname = index.getAttribute(GSXML.SHORTNAME_ATT); 189 if (shortname.equals("")) { 190 continue; 191 } 192 index_ids.add(shortname); 193 String display_name = GSXML.getDisplayText(index, GSXML.DISPLAY_TEXT_NAME, lang, "en"); 194 if (display_name.equals("")) { 195 display_name = index.getAttribute(GSXML.NAME_ATT); 196 if (display_name.equals("")) { 197 display_name = shortname; 198 } 199 } 200 index_names.add(display_name); 201 202 } 203 204 } 180 205 181 206 protected void addCustomQueryParams(Element param_list, String lang) -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java
r13732 r13911 86 86 { 87 87 super.addCustomQueryParams(param_list, lang); 88 /** lucenes rank param is based on fields, not ranked/not */88 /** lucenes rank param is based on index fields, not ranked/not */ 89 89 createParameter(RANK_PARAM, param_list, lang); 90 createParameter(FIELD_ATT, param_list, lang);91 90 } 92 91 … … 113 112 } 114 113 115 protected void getSortByIndexData(ArrayList index_ids, ArrayList index_names, String lang){ 116 // the field list - read from config file 117 Element field_list = (Element)GSXML.getChildByTagName(this.config_info, GSXML.FIELD_ELEM+GSXML.LIST_MODIFIER); 118 NodeList fields = field_list.getElementsByTagName(GSXML.FIELD_ELEM); 119 for (int i=0; i< fields.getLength();i++) { 120 String shortname = ((Element)fields.item(i)).getAttribute(GSXML.SHORTNAME_ATT); 121 String name = ((Element)fields.item(i)).getAttribute(GSXML.NAME_ATT); 122 if (name.equals("")) { 123 // no name, ignore 124 continue; 125 } 126 // TODO change field so that name is the id, and full metadata name is somthing else 127 128 if (shortname.equals("")) { 129 shortname = name; 130 } 131 if (shortname.equals("ZZ") || shortname.equals("TX")) { 132 // ZZ is a fake index, and we don't sort by TX 114 protected void getSortByIndexData(ArrayList index_ids, ArrayList index_names, String lang) { 115 // the index info - 116 Element index_list = (Element)GSXML.getChildByTagName(this.config_info, INDEX_ELEM+GSXML.LIST_MODIFIER); 117 NodeList indexes = index_list.getElementsByTagName(INDEX_ELEM); 118 int len = indexes.getLength(); 119 // now add even if there is only one 120 for (int i=0; i<len; i++) { 121 Element index = (Element)indexes.item(i); 122 String shortname = index.getAttribute(GSXML.SHORTNAME_ATT); 123 if (shortname.equals("") || shortname.equals("ZZ") || shortname.equals("TX")) { 133 124 continue; 134 125 } 135 126 index_ids.add("by"+shortname); 136 // should these be changed to a text element based on lang? 137 // or is the name of a metadata element eg dc:Title its 138 // name in all langs 139 index_names.add(name); 140 } 127 String display_name = GSXML.getDisplayText(index, GSXML.DISPLAY_TEXT_NAME, lang, "en"); 128 if (display_name.equals("")) { 129 display_name = index.getAttribute(GSXML.NAME_ATT); 130 if (display_name.equals("")) { 131 display_name = shortname; 132 } 133 } 134 index_names.add(display_name); 135 136 } 137 141 138 } 142 139 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
r13483 r13911 50 50 private MGPPWrapper mgpp_src=null; 51 51 52 private String physical_index_name = "idx"; 53 52 54 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2MGPPSearch.class.getName()); 53 55 … … 91 93 protected boolean setUpQueryer(HashMap params) { 92 94 // set up mgpp_src 93 String indexdir = GSFile.collectionBaseDir(this.site_home, this.cluster_name) + File.separatorChar + GSFile.collectionIndexPath(this.index_stem, this. default_index);95 String indexdir = GSFile.collectionBaseDir(this.site_home, this.cluster_name) + File.separatorChar + GSFile.collectionIndexPath(this.index_stem, this.physical_index_name); 94 96 this.mgpp_src.loadIndexData(indexdir); 95 97 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
r13575 r13911 72 72 Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM); 73 73 if (def != null) { 74 this.default_index = def.getAttribute(GSXML. NAME_ATT);74 this.default_index = def.getAttribute(GSXML.SHORTNAME_ATT); 75 75 } 76 76 if (this.default_index == null || this.default_index.equals("")) { -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java
r13289 r13911 79 79 80 80 81 protected void getIndexData(ArrayList index_ids, ArrayList index_names, String lang) {82 // the index info -83 Element index_list = (Element)GSXML.getChildByTagName(this.config_info, INDEX_ELEM+GSXML.LIST_MODIFIER);84 NodeList indexes = index_list.getElementsByTagName(INDEX_ELEM);85 int len = indexes.getLength();86 // now add even if there is only one87 for (int i=0; i<len; i++) {88 Element index = (Element)indexes.item(i);89 index_ids.add(index.getAttribute(GSXML.NAME_ATT));90 index_names.add(GSXML.getDisplayText(index, GSXML.DISPLAY_TEXT_NAME, lang, "en"));91 92 }93 94 }95 81 96 82 /** do the actual query */
Note:
See TracChangeset
for help on using the changeset viewer.