Marklogic search:search issue with search terms which containing hyphen(-) - search

I'm doing the search with term compte-courant. I have thesarus file which contains thesaurus entry and it's value is "comptes-courants". When I do the search, search is returning the document which is containing the "comptes" or "compte". For those result documents <search:highlight> is not available. Please help to get the documents which contains only compte-courant or comptes-courants. Please find the attached search options and result content below.
Search Option
<options xmlns="http://marklogic.com/appservices/search">
<debug>false</debug>
<search-option>score-logtfidf</search-option>
<search-option>unfiltered</search-option>
<term>
<term-option>case-insensitive</term-option>
<term-option>diacritic-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
</term>
<quality-weight>5.0</quality-weight>
<return-constraints>false</return-constraints>
<return-facets>true</return-facets>
<return-qtext>true</return-qtext>
<return-query>false</return-query>
<return-results>true</return-results>
<return-metrics>true</return-metrics>
<return-similar>false</return-similar>
<transform-results apply="src-snippet" ns="/src-snippet"
at="/src-snippet.xqy">
<per-match-tokens>30</per-match-tokens>
<max-matches>4</max-matches>
<max-snippet-chars>200</max-snippet-chars>
<preferred-elements />
</transform-results>
<additional-query>
<cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:directory-query depth="infinity">
<cts:uri>/DOCS/</cts:uri>
</cts:directory-query>
<cts:word-query>
<cts:text xml:lang="en">compte-courant</cts:text>
<cts:text xml:lang="en">comptes-courants</cts:text>
</cts:word-query>
</cts:and-query>
</additional-query>
<sort-order type="xs:date" direction="descending">
<element ns="" name="sortabledate" />
<annotation>Sort by Date</annotation>
</sort-order>
<sort-order direction="descending">
<score />
</sort-order>
<grammar>
<starter strength="40" apply="grouping" delimiter=")">(</starter>
<starter strength="10" apply="prefix" element="cts:not-query">-</starter>
<joiner strength="30" apply="infix" element="cts:and-query"
tokenize="word">AND</joiner>
<joiner strength="20" apply="infix" element="cts:or-query"
tokenize="word">OR</joiner>
</grammar>
search:search("", $searchOptions, "1", "4") returns the following result.
Result
<search:response snippet-format="src-snippet" total="640"
start="1" page-length="10" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="" xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1" uri="/DOCS/JK_KAJD-10194_MAR03.xml"
path="fn:doc("/DOCS/JK_KAJD-10194_MAR03.xml")" score="61440"
confidence="0.363169" fitness="0.534633">
<search:snippet>
<src-term />
<tool-tip>
<search:match
path="fn:doc("/DOCS/JK_KAJD-10194_MAR03.xml")/CASEDOC">Cour de justice de l'Union européenne, 4e chambre, 10 Novembre
2016 - n° C-156/15 JK_KAJD-10194_MAR03
</search:match>
</tool-tip>
<title>Cour de justice de l'Union européenne, 4e chambre, 10 Novembre
2016 - n° C-156/15
</title>
</search:snippet>
</search:result>
<search:result index="2" uri="/DOCS/JP_KID-630822_MAR03.xml"
path="fn:doc("/DOCS/JP_KID-630822_MAR03.xml")" score="61440"
confidence="0.363169" fitness="0.534633">
<search:snippet>
<src-term />
<tool-tip>
<search:match
path="fn:doc("/DOCS/JP_KID-630822_MAR03.xml")/CASEDOC">Conseil d'État, 3e sous-section, 16 Juillet 2015 - n° 388760
JP_KID-630822_MAR03
</search:match>
</tool-tip>
<title>Conseil d'État, 3e sous-section, 16 Juillet 2015 - n° 388760
</title>
</search:snippet>
</search:result>
<search:result index="3" uri="/DOCS/JP_KICA-0031257_MAR03.xml"
path="fn:doc("/DOCS/JP_KICA-0031257_MAR03.xml")" score="98304"
confidence="0.459376" fitness="0.676263">
<search:snippet>
<src-term>compte-courant</src-term>
<tool-tip>
<search:match
path="fn:doc("/DOCS/JP_KICA-0031257_MAR03.xml")/CASEDOC/*:body/*:content/*:judgments/*:judgment/*:judgmentbody/*:considerations[2]/p[13]/text">
ALORS QUE, D'AUTRE PART, en considérant que l'enregistrement des
redevances sur un
<search:highlight>compte-courant</search:highlight>
personnel valait mise à disposition des redevances de la location
gérance à M. X....
</search:match>
</tool-tip>
<title>Cour de cassation, 2e chambre civile, 9 Juillet 2015 – n°
14-21.758
</title>
</search:snippet>
</search:result>
<search:result index="4" uri="/DOCS/JP_KASS-0007470_MAR03.xml"
path="fn:doc("/DOCS/JP_KASS-0007470_MAR03.xml")" score="98304"
confidence="0.459376" fitness="0.676263">
<search:snippet>
<src-term>compte-courant</src-term>
<tool-tip>
<search:match>
ALORS QUE, D'AUTRE PART, en considérant que l'enregistrement des
redevances sur un
<search:highlight>compte-courant</search:highlight>
personnel valait mise à disposition des redevances de la location
gérance à M. X....
</search:match>
</tool-tip>
<title>Cour de cassation, 2e chambre civile, 9 Juillet 2015 – n°
14-21.755
</title>
</search:snippet>
</search:result>
<search:qtext />
<search:metrics>
<search:query-resolution-time>PT0S</search:query-resolution-time>
<search:facet-resolution-time>PT0S</search:facet-resolution-time>
<search:snippet-resolution-time>PT0.672S
</search:snippet-resolution-time>
<search:total-time>PT0.672S</search:total-time>
</search:metrics>

I think the issue you are running into is that the default search grammer treats the hyphen as "not with," so it's looking for "compte" or "comptes" without courants. It might be a different issue, but I know we had this on a recent project...try adding a different search grammar to your options. You can also wrap your search string in quotes so it is literal, but then you lose the "fuzzy" matching.
Here's a grammar that should work for this, if the root cause is what I think it is:
<grammar xmlns="http://marklogic.com/appservices/search">
<quotation>"</quotation>
<implicit>
<cts:and-query strength="20" xmlns:cts="http://marklogic.com/cts"/>
</implicit>
<starter strength="30" apply="grouping" delimiter=")">(</starter>
<joiner strength="10" apply="infix" element="cts:or-query"
tokenize="word">OR</joiner>
<joiner strength="20" apply="infix" element="cts:and-query"
tokenize="word">AND</joiner>
<joiner strength="30" apply="infix" element="cts:near-query"
tokenize="word">NEAR</joiner>
<joiner strength="30" apply="near2" consume="2"
element="cts:near-query">NEAR/</joiner>
<joiner strength="32" apply="boost" element="cts:boost-query"
tokenize="word">BOOST</joiner>
<joiner strength="35" apply="not-in" element="cts:not-in-query"
tokenize="word">NOT_IN</joiner>
<joiner strength="50" apply="constraint">:</joiner>
<joiner strength="50" apply="constraint" compare="LT"
tokenize="word">LT</joiner>
<joiner strength="50" apply="constraint" compare="LE"
tokenize="word">LE</joiner>
<joiner strength="50" apply="constraint" compare="GT"
tokenize="word">GT</joiner>
<joiner strength="50" apply="constraint" compare="GE"
tokenize="word">GE</joiner>
<joiner strength="50" apply="constraint" compare="NE"
tokenize="word">NE</joiner>
</grammar>

Related

How to restrict Primefaces inputMask to number and activate the copy and paste

I need to restrict p:inputMask to numbers only and need to activate copy and paste also, this is my code:
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
</p:inputMask>
<p:keyFilter for="numeroDocumento" mask="num" preventPaste="false" />
Could somebody help me?
I've added the "onkeypress" to your code, try this now, it will normally restrict typing to numbers only :
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
onkeypress="if((event.which < 48 && event.which != 46
&& event.which != 8) || event.which > 57) return false;">
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
</p:inputMask>
<p:keyFilter for="numeroDocumento" mask="num" preventPaste="false" />
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
Thank you very much my friend, your solution admits the dot sign buy I changed the condition on the onkeypress property and it's working successfull!
This is the solution:
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
onkeypress="if((event.which < 48 && event.which != 8) || event.which > 57) return false;" value="# dtConsultarInfController.numeroDocumento}" title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}"></p:inputMask><p:keyFilter for="numeroDocumento" mask="num"preventPaste="false" />

search:search options migration from MarkLogic 7 to version 8

I'm trying to migrate a search app written in XQuery from MarkLogic 7 to version 8 and I've hit this Known Incompatibility issue about the constraint namespace in the options. I've tried to add the default json/basic namespace and then a custom namespace, didn't work. When I run the below code in Query Console webpage looses connection and reloads after a few seconds. I've even recreated an element range index, after I installed ML 8 all my DBs were recognized, I've reindexed the target DB. Don't know what else could be wrong. Any guidance would be highly appreciated, thanks!
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
declare variable $options :=
<search:options xmlns:search="http://marklogic.com/appservices/search">
<search:search-option>unfiltered</search:search-option>
<search:page-length>30</search:page-length>
<search:term apply="term">
<search:empty apply="all-results"/>
<search:term-option>punctuation-insensitive</search:term-option>
<search:term-option>stemmed</search:term-option>
</search:term>
<search:grammar>
<search:quotation>"</search:quotation>
<search:implicit>
<cts:and-query strength="20" xmlns:cts="http://marklogic.com/cts"/>
</search:implicit>
<search:starter strength="30" apply="grouping" delimiter=")">(</search:starter>
<search:starter strength="40" apply="prefix" element="cts:not-query">-</search:starter>
<search:joiner strength="10" apply="infix" element="cts:or-query" tokenize="word">OR</search:joiner>
<search:joiner strength="20" apply="infix" element="cts:and-query" tokenize="word">AND</search:joiner>
<search:joiner strength="30" apply="infix" element="cts:near-query" tokenize="word">NEAR</search:joiner>
<search:joiner strength="30" apply="near2" consume="2" element="cts:near-query">NEAR/</search:joiner>
<search:joiner strength="50" apply="constraint">:</search:joiner>
<search:joiner strength="50" apply="constraint" compare="LT" tokenize="word">LT</search:joiner>
<search:joiner strength="50" apply="constraint" compare="LE" tokenize="word">LE</search:joiner>
<search:joiner strength="50" apply="constraint" compare="GT" tokenize="word">GT</search:joiner>
<search:joiner strength="50" apply="constraint" compare="GE" tokenize="word">GE</search:joiner>
<search:joiner strength="50" apply="constraint" compare="NE" tokenize="word">NE</search:joiner>
</search:grammar>
<search:additional-query>
<cts:not-query xmlns:cts="http://marklogic.com/cts">
<cts:or-query>
<cts:collection-query>
<cts:uri>ontology</cts:uri>
<cts:uri>Gemeentes</cts:uri>
<cts:uri>Wijken</cts:uri>
<cts:uri>Buurten</cts:uri>
<cts:uri>Wijk_Hierarchy</cts:uri>
<cts:uri>Buurt_Hierarchy</cts:uri>
<cts:uri>Kerncijfers_wijken_en_buurten_2014</cts:uri>
</cts:collection-query>
<cts:element-query>
<cts:element xmlns:sem="http://marklogic.com/semantics">sem:triples</cts:element>
<cts:or-query/>
</cts:element-query>
</cts:or-query>
</cts:not-query>
</search:additional-query>
<search:debug>false</search:debug>
<search:extract-metadata>
<search:qname elem-name="Vhe"/>
<search:qname elem-name="OpnameType"/>
<search:qname elem-name="Plaats"/>
<search:qname elem-name="Straat"/>
<search:constraint-value ref="Plaats"/>
<search:constraint-value ref="Straat"/>
<search:constraint-value ref="Keuken_Beoordeling"/>
<search:constraint-value ref="Badkamer_Beoordeling"/>
<search:constraint-value ref="location"/>
</search:extract-metadata>
<search:transform-results apply="snippet"/>
<search:constraint name="location">
<search:geo-elem-pair>
<search:parent name="location"/>
<search:lat name="lat"/>
<search:lon name="lng"/>
<search:geo-option>units=miles</search:geo-option>
<search:geo-option>coordinate-system=wgs84</search:geo-option>
<search:heatmap n="50.0006240" s="52.384274889550028" w="5.1864790" e="6.8864790" latdivs="14" londivs="19"/>
</search:geo-elem-pair>
</search:constraint>
<search:constraint name="Plaats">
<search:range type="xs:string" collation="http://marklogic.com/collation/">
<search:element name="Plaats"/>
</search:range>
</search:constraint>
<search:constraint name="Straat">
<search:range type="xs:string" collation="http://marklogic.com/collation/">
<search:element name="Straat"/>
</search:range>
</search:constraint>
<search:constraint name="Complex">
<search:range type="xs:string" collation="http://marklogic.com/collation/">
<search:element name="Complex"/>
</search:range>
</search:constraint>
<search:constraint name="Keuken_Beoordeling">
<search:range type="xs:string" collation="http://marklogic.com/collation/">
<search:element name="Keuken_Beoordeling"/>
</search:range>
</search:constraint>
<search:constraint name="Badkamer_Beoordeling">
<search:range type="xs:string" collation="http://marklogic.com/collation/">
<search:element name="Badkamer_Beoordeling"/>
</search:range>
</search:constraint>
<search:return-metrics>true</search:return-metrics>
<search:return-qtext>true</search:return-qtext>
<search:return-query>false</search:return-query>
<search:return-results>true</search:return-results>
<search:return-similar>false</search:return-similar>
<search:sort-order direction="descending">
<search:score/>
<search:annotation>Relevancy (Desc)</search:annotation>
</search:sort-order>
</search:options>;
search:search("wieer", $options, xs:unsignedLong(1), 150)
As Joe points out, the server may be crashing and automatically restarting. Check ErrorLog.txt to verify that. Make sure you have the very latest release: right now it's 8.0-1.1.
The test case does not crash on my laptop with 8.0-1.1 and the necessary index settings. However I don't have any matching documents so it doesn't do very much. That may mean that the crash, if that's what's happening, requires some of your content too. You could try an empty database to verify that, then try to establish whether or not the problem is linked to a specific set of documents.
If the problem persists, contact support to report it.
I've recreated the DB from scratch, copied data with the latest mlcp from the ML 7 DB to the newly created ML 8 DB. Recreated the indexes, but the crash was still happening. Then, I filtered out from the search options which section caused the crash. It is this one:
<search:constraint name="location">
<search:geo-elem-pair>
<search:parent name="location"/>
<search:lat name="lat"/>
<search:lon name="lng"/>
<search:geo-option>units=miles</search:geo-option>
<search:geo-option>coordinate-system=wgs84</search:geo-option>
<search:heatmap n="50.0006240" s="52.384274889550028" w="5.1864790" e="6.8864790" latdivs="14" londivs="19"/>
</search:geo-elem-pair>
</search:constraint>
Once I removed this, was not really using it in the search results, there were no more issues.

How to make a single column in Telerik Radgrid Resizable?

I have the following Telerik RadGrid.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AllowSorting="true"
PageSize="50" HeaderStyle-Height="20" ShowStatusBar="true" AllowCustomPaging="True"
OnNeedDataSource="RadGrid1_NeedDataSource" OnSortCommand="RadGrid1_SortCommand"
OnPageSizeChanged="RadGrid1_PageSizeChanged" OnPageIndexChanged="RadGrid1_PageIndexChanged"
OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound">
<clientsettings>
<Selecting AllowRowSelect="True" />
<Resizing EnableRealTimeResize="true" />
</clientsettings>
<exportsettings filename="list">
</exportsettings>
<mastertableview datakeynames="ID" autogeneratecolumns="false">
<PagerStyle AlwaysVisible="true" PagerTextFormat="{4} {5} item(s) in {1} page(s)" />
<Columns>
<telerik:GridBoundColumn DataField="Contract" HeaderStyle-Width="20%" HeaderText="Contract Title"
UniqueName="Contract" SortExpression="Contract"> </telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Customer" HeaderStyle-Width="20%" HeaderText="Vendor"
UniqueName="Vendor" SortExpression="Customer"> </telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Contractor" HeaderStyle-Width="20%" HeaderText="Contractor"
UniqueName="Contractor" SortExpression="Contractor"></telerik:GridBoundColumn>
**<telerik:GridBoundColumn DataField="Name" HeaderText="Service"
UniqueName="Name" SortExpression="Name" Resizable="true"> </telerik:GridBoundColumn>**
</Columns>
</mastertableview>
</telerik:RadGrid>
I want to make only the last column (Name) resizable. I used Resizable="true" but it is not working. Is there any other way for it?
You need to add AllowColumnResize="True" on RadGrid and you can disable other column's resize properties by using Resizable="False".

Parsing xml data into nested list bash

I'm working on a Plex Geeklet, and I have a string of recently added TV shows.
SHOW_DATA=$(curl --silent "http://localhost:32400/library/sections/3/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=10")
This is an example of my data:
<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="10" totalSize="50" allowSync="1" art="/:/resources/show-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="3" librarySectionTitle="TV Shows" librarySectionUUID="600cd0c5-fd4b-460a-846b-e4bad1ecdf4a" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1402960845" mixedParents="1" nocache="1" offset="0" thumb="/:/resources/show.png" title1="TV Shows" title2="Recently Added" viewGroup="episode" viewMode="65592">
<Video ratingKey="588" key="/library/metadata/588" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Pilot" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Fast-talking lawyer Jeff Winger (Joel McHale) enrolls at Greendale Community College after the State Bar discovered his illegitimate degree and threatened to suspend his license. When Jeff pretends to be a Spanish tutor to get close to his classmate Britta (Gillian Jacobs), he winds up with an entire study group of students looking for his help. Pierce (Chevy Chase), Abed (Danny Pudi), Shirley (Yvette Nicole Brown), Annie (Alison Brie), Troy (Donald Glover), and Britta comprise the band of misfits that Jeff never asked for, but may end up needing when he realizes his connection to Greendale professor Ian Duncan (John Oliver) won&apos;t pay off like he hoped." index="1" parentIndex="1" rating="7.4000000953674299" year="2009" thumb="/library/metadata/588/thumb/1403755683" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1525134" originallyAvailableAt="2009-09-17" addedAt="1403755618" updatedAt="1403755683">
<Media videoResolution="480" id="479" duration="1525134" bitrate="2509" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="522" key="/library/parts/522/file.mp4" duration="1525134" file="/Users/joe/Videos/TV Shows/Community/Season 1/01 Pilot.mp4" size="478232014" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Dan Harmon" />
<Director tag="Anthony Russo" />
<Director tag="Joe Russo" />
</Video>
<Video ratingKey="589" key="/library/metadata/589" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Spanish 101" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Jeff&apos;s (Joel McHale) efforts to win over Britta (Gillian Jacobs) backfire, and he finds himself paired up with Pierce (Chevy Chase) for their Spanish class project. The two give teacher Señor Chang (Ken Jeong) the presentation of a lifetime. Meanwhile, inspired by Britta&apos;s awareness of social issues, Annie (Alison Brie) and Shirley (Yvette Nicole Brown) stage a protest on Greendale&apos;s campus." index="2" parentIndex="1" rating="7.4000000953674299" year="2009" thumb="/library/metadata/589/thumb/1403755684" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1278352" originallyAvailableAt="2009-09-24" addedAt="1403755618" updatedAt="1403755684">
<Media videoResolution="480" id="480" duration="1278352" bitrate="2253" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="523" key="/library/parts/523/file.mp4" duration="1278352" file="/Users/joe/Videos/TV Shows/Community/Season 1/02 Spanish 101.mp4" size="359953984" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Dan Harmon" />
<Director tag="Joe Russo" />
</Video>
<Video ratingKey="591" key="/library/metadata/591" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Introduction to Statistics" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="It&apos;s Halloween at Greendale, and Jeff (Joel McHale) has the hots for one of his teachers (Lauren Stamile) and gets dating advice from Señor Chang (Ken Jeong). Meanwhile Annie (Alison Brie) throws a ""Dia de los Muertos" party for extra credit." index="7" parentIndex="1" rating="7.9000000953674299" year="2009" thumb="/library/metadata/591/thumb/1403755686" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1276610" originallyAvailableAt="2009-10-29" addedAt="1403755618" updatedAt="1403755686">
<Media videoResolution="480" id="482" duration="1276610" bitrate="2258" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="525" key="/library/parts/525/file.mp4" duration="1276610" file="/Users/joe/Videos/TV Shows/Community/Season 1/07 Introduction to Statistics.mp4" size="360268838" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Jon Pollack" />
<Writer tag="Tim Hobert" />
<Director tag="Justin Lin" />
</Video>
<Video ratingKey="592" key="/library/metadata/592" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Home Economics" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Britta (Gillian Jacobs) tries to rid Jeff (Joel McHale) of his materialistic ways. Meanwhile Pierce (Chevy Chase) joins a rock band on campus, and Annie (Alison Brie) grudgingly helps Troy (Donald Glover) plan a date with another girl." index="8" parentIndex="1" rating="7.5999999046325701" year="2009" thumb="/library/metadata/592/thumb/1403755686" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1275844" originallyAvailableAt="2009-11-05" addedAt="1403755618" updatedAt="1403755686">
<Media videoResolution="480" id="483" duration="1275844" bitrate="2340" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="526" key="/library/parts/526/file.mp4" duration="1275844" file="/Users/joe/Videos/TV Shows/Community/Season 1/08 Home Economics.mp4" size="373156573" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Lauren Pomerantz" />
<Director tag="Anthony Russo" />
</Video>
<Video ratingKey="593" key="/library/metadata/593" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Comparative Religion" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Shirley (Yvette Nicole Brown) tries to get everyone in the Christmas spirit, but Jeff (Joel McHale) threatens her holiday cheer when he decides to fight the school bully (guest star Anthony Michael Hall)." index="12" parentIndex="1" rating="7.8000001907348597" year="2009" thumb="/library/metadata/593/thumb/1403755688" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1276355" originallyAvailableAt="2009-12-10" addedAt="1403755618" updatedAt="1403755688">
<Media videoResolution="480" id="484" duration="1276355" bitrate="2446" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="527" key="/library/parts/527/file.mp4" duration="1276355" file="/Users/joe/Videos/TV Shows/Community/Season 1/12 Comparative Religion.mp4" size="390216047" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Liz Cackowski" />
<Director tag="Adam Davidson" />
</Video>
<Video ratingKey="594" key="/library/metadata/594" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Investigative Journalism" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Everyone&apos;s vibe is thrown off when an unwanted outsider tries to join the study group. Meanwhile, Jeff (Joel McHale) becomes the new editor of Greendale&apos;s school newspaper and appoints Annie (Alison Brie) as his ace reporter." index="13" parentIndex="1" rating="7.5" year="2010" thumb="/library/metadata/594/thumb/1403755689" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1269923" originallyAvailableAt="2010-01-14" addedAt="1403755618" updatedAt="1403755689">
<Media videoResolution="480" id="485" duration="1269923" bitrate="1998" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="528" key="/library/parts/528/file.mp4" duration="1269923" file="/Users/joe/Videos/TV Shows/Community/Season 1/13 Investigative Journalism.mp4" size="317146865" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Jon Pollack" />
<Writer tag="Tim Hobert" />
<Director tag="Joe Russo" />
</Video>
<Video ratingKey="595" key="/library/metadata/595" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Romantic Expressionism" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Britta (Gillian Jacobs) and Jeff (Joel McHale) stage an intervention when Annie (Alison Brie) gets cozy with Vaughn (Eric Christian Olsen). Meanwhile Pierce (Chevy Chase) struggles to prove his wit when he crashes Abed (Danny Pudi) and Troy’s (Donald Glover) movie night." index="15" parentIndex="1" rating="7.9000000953674299" year="2010" thumb="/library/metadata/595/thumb/1403755689" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1274799" originallyAvailableAt="2010-02-04" addedAt="1403755618" updatedAt="1403755689">
<Media videoResolution="480" id="486" duration="1274799" bitrate="2059" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="529" key="/library/parts/529/file.mp4" duration="1274799" file="/Users/joe/Videos/TV Shows/Community/Season 1/15 Romantic Expressionism.mp4" size="328027632" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Andrew Guest" />
<Director tag="Joe Russo" />
</Video>
<Video ratingKey="596" key="/library/metadata/596" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Communication Studies" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="When Britta (Gillian Jacobs) drunk dials Jeff (Joel McHale) things get awkward between them and Jeff attempts to repair their relationship. Meanwhile, Annie (Alison Brie) and Shirley (Yvette Nicole Brown) conspire to humiliate Señor Chang (Ken Jeong)." index="16" parentIndex="1" rating="7.8000001907348597" year="2010" thumb="/library/metadata/596/thumb/1403755691" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1267206" originallyAvailableAt="2010-02-11" addedAt="1403755618" updatedAt="1403755691">
<Media videoResolution="480" id="487" duration="1267206" bitrate="2278" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="530" key="/library/parts/530/file.mp4" duration="1267206" file="/Users/joe/Videos/TV Shows/Community/Season 1/16 Communication Studies.mp4" size="360777073" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Chris McKenna" />
<Director tag="Adam Davidson" />
</Video>
<Video ratingKey="597" key="/library/metadata/597" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Modern Warfare" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="JEFF AND BRITTA&apos;S SEXUAL TENSION HEATS UP ? The sexual tension between Jeff (Joel McHale) and Britta (Gillian Jacobs) becomes a hot topic among the study group. Meanwhile, what starts out as a simple contest for a chance at early class registration turns the peaceful campus of Greendale Community College into an all-out war zone. Friendships are tested, as only one student can be victorious." index="23" parentIndex="1" rating="8.5" year="2010" thumb="/library/metadata/597/thumb/1403755692" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" duration="1260333" originallyAvailableAt="2010-05-06" addedAt="1403755618" updatedAt="1403755692">
<Media videoResolution="480" id="488" duration="1260333" bitrate="2233" width="854" height="480" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" has64bitOffsets="0">
<Part id="531" key="/library/parts/531/file.mp4" duration="1260333" file="/Users/joe/Videos/TV Shows/Community/Season 1/23 Modern Warfare.mp4" size="351822199" container="mp4" has64bitOffsets="0" optimizedForStreaming="0" />
</Media>
<Writer tag="Emily Cutler" />
<Director tag="Justin Lin" />
</Video>
<Video ratingKey="590" key="/library/metadata/590" parentRatingKey="587" grandparentRatingKey="586" type="episode" title="Advanced Criminal Law" grandparentKey="/library/metadata/586" parentKey="/library/metadata/587" grandparentTitle="Community" contentRating="TV-PG" summary="Señor Chang (Ken Jeong) invokes an inquisition and trial when one of the gang cheats on an exam. Annie (Alison Brie) enlists Pierce (Chevy Chase) to help her compose Greendale&apos;s new school song, and Troy (Donald Glover) educates Abed (Danny Pudi) on the art of joking." index="5" parentIndex="1" rating="7.8000001907348597" year="2009" thumb="/library/metadata/590/thumb/1403755683" art="/library/metadata/586/art/1403755684" parentThumb="/library/metadata/587/thumb/1403755684" grandparentThumb="/library/metadata/586/thumb/1403755684" grandparentTheme="/library/metadata/586/theme/1403755684" originallyAvailableAt="2009-10-15" addedAt="1403755618" updatedAt="1403755683">
<Media id="481" container="">
<Part id="524" key="/library/parts/524/file.mp4" file="/Users/joe/Videos/TV Shows/Community/Season 1/05 Advanced Criminal Law.mp4" size="48" />
</Media>
<Writer tag="Andrew Guest" />
<Director tag="Joe Russo" />
</Video>
</MediaContainer>
I'm trying to get this into an orders list like this
[ [show_title_1, episode_title_1], [show_title_2, episode_title_2], ... [show_title_10, episode_title_10] ]
so I can eventually print it as (for example)
Community: Pilot
Arrested Development: My Mother, the Car
I've been able to get them into separate newline-delimited strings like so:
SHOW_NAMES=$("$SHOW_DATA" | grep -o 'grandparentTitle="\([^"]*\)"' | sed -e 's/grandparentTitle="//' -e 's/"//' | perl -MHTML::Entities -ne 'print decode_entities($_)'))
SHOW_TITLES=$("$SHOW_DATA" | grep -o 'title="\([^"]*\)"' | sed -e 's/title="//' -e 's/"//' | perl -MHTML::Entities -ne 'print decode_entities($_)'))
So is it possible to convert them both to lists, and use a loop to construct a new list containing nested lists of those values? I've really hit a wall here.
If I were you I would get rid of all the grep and sed, etc.. and just rely on pattern matching. I guessed at which exact fields you wanted, but you can easily update the code as needed. I used your data file to test with, so this will work. The script takes 1 input, that being the filename to the downloaded .xml file:
#!/bin/bash
test -r "$1" || { echo "error: invalid input, usage: ${0//*\//} filename.xml"; exit 1; }
let idx=0
while read line || test -n "$line"; do
if test "${line:0:2}" == '<V'; then
tmp=${line##* title=}
title=${tmp%% grandparentKey*}
tmp=${line##*grandparentTitle=}
gptitle=${tmp%% contentRating*}
if test "$idx" -lt "1" ; then
let idx=1
echo -n "[ [ $title, $gptitle ]"
else
echo -n ", [ $title, $gptitle ]"
fi
fi
done <"$1"
echo " ]"
exit 0
The following will read the values into an array to allow later processing. You can add additional arrays as you like, you can even read the entire file into an array if you like (but re-reading if from disk is simple enough as well) The output is the same as above (it is just for illustration):
let idx=0
declare -a title
declare -a gptitle
declare -a allvideo
while read line || test -n "$line"; do
if test "${line:0:2}" == '<V'; then
allvideo+=( "$line" )
tmp=${line##* title=}
title+=( "${tmp%% grandparentKey*}" )
tmp=${line##*grandparentTitle=}
gptitle+=( "${tmp%% contentRating*}" )
fi
done <"$1"
# output the original 2 variables
for ((i=0; i<${#title[#]}; i++)); do
if test "$i" -eq 0 ; then
echo -n "[ [ ${title[$i]}, ${gptitle[$i]} ]"
else
echo -n ", [ ${title[$i]}, ${gptitle[$i]} ]"
fi
done
echo " ]"
oldifs=$IFS
IFS=$'\n' # set Internal Field Separator to only break on newlines
# output the entire file with the allvideo array
for i in ${allvideo[#]}; do
echo "$i"
done
IFS=$oldifs
output:
[ [ "Pilot", "Community" ], [ "Spanish 101", "Community" ], \
[ "Introduction to Statistics", "Community" ], [ "Home Economics", "Community" ], \
[ "Comparative Religion", "Community" ], [ "Investigative Journalism", "Community" ], \
[ "Romantic Expressionism", "Community" ], [ "Communication Studies", "Community" ], \
[ "Modern Warfare", "Community" ], [ "Advanced Criminal Law", "Community" ] ]
**the dump of the original file is omitted for brevity.
Let me know if you have any additional questions.

Solr wrong sort text fields

I have "text_general" field in schema.xml
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/><filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
I have stored documents:
document1:
spell = "contro un indice generale dei prezzi salito del 2, 1%. Rincari ben piщ evidenti, tra i prodotti da bar"
testata = "Mattino di Padova (Il)"
document2:
spell="con i prodotti di qualitа vinco la crisi dei consumi Farinetti: con"
testata = "Italia Oggi"
document3
spell = "convenienza Il 2008 porta i primi aumenti nei pre zi L'Ipercoop cresce il listino"
testata = "Nuova Ferrara (La)"
"spell" and "testata" fields has a "text_general" type.
Searching working fine for me:
http://localhost:8080/solr/select?q={!type=edismax qf=spell v='co*'}
But with sorting exists some problem:
http://localhost:8080/solr/select?q={!type=edismax qf=spell v='co*'}&sort=testata desc
It returns me this result:
document1:
spell = "contro un indice generale dei prezzi salito del 2, 1%. Rincari ben piщ evidenti, tra i prodotti da bar"
testata = "Mattino di Padova (Il)"
document2:
spell="con i prodotti di qualitа vinco la crisi dei consumi Farinetti: con"
testata = "Italia Oggi"
document3
spell = "convenienza Il 2008 porta i primi aumenti nei pre zi L'Ipercoop cresce il listino"
testata = "Nuova Ferrara (La)"
I don`t understand why my sorting working not properly. It should returns me result like this:
document3
spell = "convenienza Il 2008 porta i primi aumenti nei pre zi L'Ipercoop cresce il listino"
testata = "Nuova Ferrara (La)"
document1:
spell = "contro un indice generale dei prezzi salito del 2, 1%. Rincari ben piщ evidenti, tra i prodotti da bar"
testata = "Mattino di Padova (Il)"
document2:
spell="con i prodotti di qualitа vinco la crisi dei consumi Farinetti: con"
testata = "Italia Oggi"
Sorting doesn't work good on multivalued and tokenized fields.
As testata has been defined with text_general field type, it will be tokensized and hence the sort would not work fine.
Sorting can be done on the "score" of the document, or on any
multiValued="false" indexed="true" field provided that field is either
non-tokenized (ie: has no Analyzer) or uses an Analyzer that only
produces a single Term (ie: uses the KeywordTokenizer)
Source: http://wiki.apache.org/solr/CommonQueryParameters#sort
Use string as the field type and copy the title field into the new field.
<field name="testata_sort" type="string" indexed="true" stored="false"/>
<copyField source="testata" dest="testata_sort" />

Resources