Changeset 13911


Ignore:
Timestamp:
2007-02-14T16:29:04+13:00 (17 years ago)
Author:
kjdon
Message:

changed the format of index and field info in buildConfig and collectionConfig. No fields any more, just use indexes. index has a shortname and a name - name comes from collect.cfg, shortname from build.cfg, eg text and TX, or section:text and ste. mg/mgpp/lucene colls config files are more similar now

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  
    8989   // the default level for retrieval - and we'll use it for searching too
    9090    protected String default_level=null;
    91     // the default field for searching
    92     protected String default_field = null;
     91
    9392    // which search services will we offer??
    9493    protected boolean plain_search = false;
     
    161160    }
    162161
    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   
    172163    // the format info is the same for all services
    173164    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
    180167    if (this.simple_form_search) {
    181168        // set up short_service_info_ - for now just has id and type - name will be added in on the fly
     
    348335   
    349336    }
    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 index
    352            
    353     // the field list -  read from config file
    354     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, ignore
    361         continue;
    362         }
    363         // TODO change field so that name is the id, and full metadata name is somthing else
    364         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 its
    370         // name in all langs
    371         index_names.add(name);
    372     }
    373     }
    374 
    375337
    376338    // the following three functions are needed so the base class can
     
    441403    String field = (String) params.get(INDEX_PARAM);
    442404    if (field == null) {
    443         field = default_field;
     405        field = default_index;
    444406    }
    445407   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2Search.java

    r13270 r13911  
    9797    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM);
    9898    if (def != null) {
    99         this.default_index = def.getAttribute(GSXML.NAME_ATT);
     99        this.default_index = def.getAttribute(GSXML.SHORTNAME_ATT);
    100100    } // otherwise will be "", and the first one will be the default
    101101
     
    178178    }
    179179
     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    }
    180205
    181206    protected void addCustomQueryParams(Element param_list, String lang)
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2LuceneSearch.java

    r13732 r13911  
    8686    {
    8787    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 */
    8989    createParameter(RANK_PARAM, param_list, lang);
    90     createParameter(FIELD_ATT, param_list, lang);
    9190    }
    9291   
     
    113112    }
    114113   
    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")) {
    133124        continue;
    134125        }
    135126        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   
    141138    }
    142139
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java

    r13483 r13911  
    5050    private MGPPWrapper mgpp_src=null;
    5151
     52    private String physical_index_name = "idx";
     53   
    5254    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2MGPPSearch.class.getName());
    5355
     
    9193    protected boolean setUpQueryer(HashMap params) {
    9294    // 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);
    9496    this.mgpp_src.loadIndexData(indexdir);
    9597
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java

    r13575 r13911  
    7272    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM);
    7373    if (def != null) {
    74         this.default_index = def.getAttribute(GSXML.NAME_ATT);
     74        this.default_index = def.getAttribute(GSXML.SHORTNAME_ATT);
    7575    }
    7676    if (this.default_index == null || this.default_index.equals("")) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java

    r13289 r13911  
    7979   
    8080
    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 one
    87     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     }
    9581
    9682    /** do the actual query */
Note: See TracChangeset for help on using the changeset viewer.