Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-14879

Update PageProvider interface and service so as to include Aggregates support

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.0
    • Component/s: Query & PageProvider

      Description

      • a method for getting the aggregates. Aggregates should be typed.
      • a contribution for specifying aggregates that should be fetched, unless this is done in NXQL (to be specified)
      • an implementation of the construction of the query for elastic search, in the ElasticSearchPageProvider.

      Unsupported on other Page providers.

      About contribution for specifying aggregates
      This involves to define the descriptors to be added to the page provider definition in order to contribute all the aggregates that will have to be returned along with the query result.

      About an aggregate:

      • it has a unique id within the scope of a content view
      • it is on a particular document property.
      • it has a type

      Aggregate types can be found in ES doc. We'll first foucs on two types:

      • cardinality (for string document properties)
      • histogram (for date/numeric document properties)

      Depending on the type of the aggregate, additional information options to be added in the page provider definition. For instance, the cardinality have a precision_threshold option and histogram have interval option. This kind of option will be given dynamically from the higher layer but we might want to set default values.

      Suggestion of implementation

      Page Provider definition

          <contentView name="advanced_search">
      
            <title>command.advancedSearch</title>
            <translateTitle>true</translateTitle>
            <showTitle>true</showTitle>
      
            <emptySentence>label.content.empty.search</emptySentence>
            <translateEmptySentence>true</translateEmptySentence>
      
            <genericPageProvider name="AdvancedSearch_ES"
              class="org.nuxeo.elasticsearch.provider.ElasticSearchNxqlPageProvider">
      
              <property name="coreSession">#{documentManager}</property>
              <property name="maxResults">-1</property>
      
              <aggregates docType="AdvancedSearch">
               
                  <aggregate id="dc_coverage_agg" type="term" parameter="dc:coverage">
                    <field schema="advanced_search" name="coverage_agg" />
                    <properties>
                      <property name="precision_threshold">100</property>
                      <property name="rehash">false</property>
                    </properties>
                  </aggregate>
      
                   <aggregate id="dc_created_agg" type="date_histogram" parameter="dc:created">
                    <field schema="advanced_search" name="created_agg" />
                    <properties>
                      <property name="interval">1M</property>
                      <property name="format">yyyy-MM-dd"</property>
                    </properties>
                  </aggregate>
      
                  <aggregate id="common_size_agg" type="histogram" parameter="common:size">
                    <field schema="advanced_search" name="size_agg" />
                    <properties>
                      <property name="interval">1000</property>
                      <property name="min_doc_count">10</property>
                    </properties>
                  </aggregate>
      
                 <!-- we can even define aggregate properties directly in json -->
                <aggregate id="rings_around_amsterdam" type="geo_distance" parameter="dc:location">
                  <field schema="advanced_search" name="zzz" />
                  <jsonProperties>
                     {
                       "origin" : "52.3760, 4.894",
                       "ranges" : [
                          { "to" : 100 },
                          { "from" : 100, "to" : 300 },
                          { "from" : 300 }
                       ]
                     }
          
                  </jsonProperties>
                </aggregate>
              </aggregates>
      
              <whereClause docType="AdvancedSearch">
                    .....
              </whereClause>
              <!-- sort column="dc:title" ascending="true" / sort by fulltext relevance -->
              <pageSize>20</pageSize>
              <sortInfosBinding>
                #{documentSearchActions.searchSortInfos}
              </sortInfosBinding>
            </genericPageProvider>
      
            <searchLayout name="advanced_search" />
      
            <aggregationLayout name="advanced_search_agg" />
            ....
          </contentView>
      

      Aggregation Layout definition:

          <layout name="advanced_search_agg">
            <templates>
              <template mode="any">/layouts/layout_default_template.xhtml</template>
            </templates>
            <rows>
              <row>
                <widget>dc_coverage_agg_widget</widget>
              </row>
              <row>
                <widget>common_size_agg_widget</widget>
              </row>
              <row>
                <widget>dc_created_agg</widget>
              </row>
            </rows>
          </layout>
      
          <widget name="dc_coverage_agg_widget" type="manyCheckboxOrMultipleSelect2IfTooMany">
            <labels>
              <label mode="any">Select coverage</label>
            </labels>
            <translated>false</translated>
            <fields>
              <field>advanced_search:coverage</field>
            </fields>
            <properties mode="any">
              <property name="width">300</property>
              <property name="minChars">0</property>
              <property name="directoryName">l10ncoverage</property>
            </properties>
            <selectOptions>
              <options value="#{aggregateFormatterBean.formatDirEntries('l10ncoverage',aggregates['dc_coverage_agg'])}"  var="item" itemValue="#{item.id}" itemLabel="#{item.label}" />
            </selectOptions>
          </widget>
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 week
                  1w
                  Remaining:
                  Remaining Estimate - 1 week
                  1w
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.