2013-02-28 83 views
0

我使用Solr 3.6.2爲我確定要包含特定字符串的文檔提取片段。 (首先,這個用法是否正確?)不幸的是,我得到的片段不包含我的查詢字符串(簡單,單一,不停止的單詞)。對於包含查詢詞的文檔不返回Solr文檔片段

例如,對於文檔123456,我知道含有 「funmitflags」,我有這種類型的查詢:

id:123456 and content_en:funmitflags 

fl=id&hl=true&hl.fl=content_en&hl.snippets=2&hl.alternateField=content_en&hl.maxAlternateFieldLength=400&hl.maxAnalyzedCharacters=2147483647&hl.fragsize=400&rows=100 

(我把我的「content_en 「 我通常在這個領域有大量的文本。) 但是,現在我通常會返回前400個字符,而不是那些包含我的」funmitflags「單詞的字符。

我可以從管理頁面檢索文檔,無論如何,只是不是一個適當的亮點。 這是尷尬的,因爲我有約75%的所有查詢這個問題。

在我的schema.xml中,我將「content_en」定義爲「text_en」。

<field name="content_en" type="text_en" indexed="true" stored="true" />

我改變 「text_en」,從最初的定義,下列:

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer type="index"> 
    <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
    <filter class="solr.StopFilterFactory" 
      ignoreCase="true" 
      words="lang/stopwords_en.txt" 
      enablePositionIncrements="true" 
      /> 
    <filter class="solr.WordDelimiterFilterFactory" 
      generateWordParts="1" 
      generateNumberParts="1" 
      catenateWords="0" 
      catenateNumbers="0" 
      catenateAll="0" 
      splitOnCaseChange="1"/> 
    <filter class="solr.LowerCaseFilterFactory"/> 
<filter class="solr.EnglishPossessiveFilterFactory"/> 
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> 
    <filter class="solr.PorterStemFilterFactory"/> 
    </analyzer> 
    <analyzer type="query"> 
    <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
    <filter class="solr.WordDelimiterFilterFactory" 
      generateWordParts="1" 
      generateNumberParts="1" 
      catenateWords="0" 
      catenateNumbers="0" 
      catenateAll="0" 
      splitOnCaseChange="1"/> 
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> 
    <filter class="solr.StopFilterFactory" 
      ignoreCase="true" 
      words="lang/stopwords_en.txt" 
      enablePositionIncrements="true" 
      /> 
    <filter class="solr.LowerCaseFilterFactory"/> 
<filter class="solr.EnglishPossessiveFilterFactory"/> 
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> 
    <filter class="solr.PorterStemFilterFactory"/> 
    </analyzer> 
</fieldType> 

重建索引,我得到了這兩種情況下沒有正確的片段。 有人可以給我一個方向嗎? 我應該總是得到一個包含我的搜索的片段單詞

回答

0

感謝@ Arun的實驗這削減了一半的可能性,我找到了一個解決方案。

  • 由於我的文本是非常大的,我solrconfig.xml中

    <maxFieldLength>1000000</maxFieldLength>

  • 爲了提高速度設定,我開始使用fastVectorHighlighter:

    solrQuery.set("hl.useFastVectorHighlighter", true); 到我的查詢。似乎它禁用了我的highligherSimplePre和highligherSimplePost,但誰在乎。

此外,我不得不術語*選項添加到我的內容領域:

` <field name="content_en" type="text_en" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />` 
  • Ofcourse,重新索引進行。
+0

很高興我的實驗幫助你排除了一半的可能性:-)。 – arun 2013-03-01 14:13:01

1

剛剛試過突出顯示text_en類型的字段largetext_en,它使用您的分析儀鏈。突出顯示工作正常,4個片段包含搜索詞Polyana,如下所示。 (這是很難閱讀下面的字段的內容,因此複製粘貼到文本編輯器,看看。)

http://localhost:8983/solr/collection1/select?q=id:mateva_highlight%20AND%20largetext_en:polyana&wt=json&fl=id,largetext_en&hl=true&hl.fl=largetext_en&hl.snippets=10&hl.alternateField=largetext_en&hl.maxAlternateFieldLength=400&hl.maxAnalyzedCharacters=2147483647&hl.fragsize=400&rows=100

這裏是輸出:

responseHeader: { 
status: 0 
QTime: 5 
-params: { 
hl.fragsize: "400" 
fl: "id,largetext_en" 
hl.snippets: "10" 
hl.maxAlternateFieldLength: "400" 
q: "id:mateva_highlight AND largetext_en:polyana" 
hl.alternateField: "description" 
hl.fl: "largetext_en" 
wt: "json" 
hl: "true" 
-rows: [ 
"41" 
"100" 
] 
hl.maxAnalyzedCharacters: "2147483647" 
} 
} 
-response: { 
numFound: 1 
start: 0 
-docs: [ 
-{ 
id: "mateva_highlight" 
-largetext_en: [ 
"COUNT LEO NIKOLAYEVICH TOLSTOY was born August 28, 1828, at the family estate of Yasna- ya Polyana, in the province of Tula. His moth- er died when he was three and his father six years later. Placed in the care of his aunts, he passed many of his early years at Kazan, where, in 1844, after a preliminary training by French tutors, he entered the university. He cared lit- tle for the university and in 1847 withdrew be- cause of "ill-health and domestic circum- stances." He had, however, done a great deal of reading, of French, English, and Russian novels, the New Testament, Voltaire, and Hegel. The author exercising the greatest in- fluence upon him at this time was Rousseau; he read his complete works and for sometime wore about his neck a medallion of Rousseau. Immediately upon leaving the university, Tolstoy returned to his estate and, perhaps inr spired by his enthusiasm for Rousseau, pre- pared to devote himself to agriculture and to improving the condition of his serfs. His first attempt at social reform proved disappointing, and after six months he withdrew to Moscow and St. Petersburg, where he gave himself over to the irregular life characteristic of his class and time. In 1851, determined to "escape my debts and, more than anything else, my hab- its," he enlisted in the Army as a gentleman- volunteer, and went to the Caucasus. While at Tiflis, preparing for his examinations as a cadet, he wrote the first portion of the trilogy, Childhood, Boyhood, and Youth, in which he celebrated the happiness of "being with Na- ture, seeing her, communing with her." He al- so began The Cossacks with the intention of showing that culture is the enemy of happi- ness. Although continuing his army life, he gradually came to realize that "a military ca- reer is not for me, and the sooner I get out of it and devote myself entirely to literature the better." His Sevastopol Sketches (1855) were so successful that Czar Nicholas issued special orders that he should be removed from a post of danger. Returning to St. Petersburg, Tolstoy was re- ceived with great favor in both the official and literary circles of the capital. He soon became interested in the popular progressive move- ment of the time, and in 1857 he decided to go abroad and study the educational and munici- pal systems of other countries. That year, and again in 1860, he traveled in Europe. At Yas- naya Polyana in 1861 he liberated his serfs and opened a school, established on the principle that "everything which savours of compulsion is harmful." He started a magazine to promote his notions on education and at the same time served as an official arbitrator for grievances between the nobles and the recently emanci- pated serfs. By the end of 1863 he was so ex- hausted that he discontinued his activities and retired to the steppes to drink koumis for his health. Tolstoy had been contemplating marriage for some time, and in 1862 he married Sophie Behrs, sixteen years his junior, and the daugh- ter of a fashionable Moscow doctor. Their early married life at Yasnaya Polyana was tranquil. Family cares occupied the Countess, and in the course of her life she bore thirteen children, nine of whom survived infancy. Yet she also acted as a copyist for her husband, who after their marriage turned again to writ- ing. He was soon at work upon "a novel of the i8io's and *2o's" which absorbed all his time and effort. He went frequently to Mos- cow, "studying letters, diaries, and traditions" and "accumulated a whole library" of histori- cal material on the period. He interviewed survivors of the battles of that time and trav- eled to Borodino to draw up a map of the battleground. Finally, in 1869, after his work had undergone several changes in conception and he had "spent five years of uninterrupted andjgxceptionally strenuous labor Tnnierthe IbesfcondUtions of life/' he published War and Peace. Its appearance immediately established Tolstoy's reputation, and in the judgment of Turgenev, the acknowledged dean of Russian letters, gave him "first place among all our contemporary writers." The years immediately following the com- pletion of War and Peace were pa**efl in a great variety of occupations, none of which Tohtoy found satisfying. He tried busying VI BIOGRAPHICAL NOTE himself with the affairs of his estate, under- took the learning of Greek to read the ancient classics, turned again to education, wrote a series of elementary school books, and served as school inspector. With much urging from his wife and friends, he completed Anna Kare- nina, which appeared serially between 1875 and 1877. Disturbed by what he considered his unreflective and prosperous existence, Tolstoy became increasingly interested in religion. At first he turned to the orthodox faith of the people. Unable to find rest there, he began a detailed examination of religions, and out of his reading, particularly of the Gospels, gradu- ally evolved his own personal doctrine. Following his conversion, Tolstoy adopted a new mode of life. He dressed like a peasant, devoted much of his time to manual work, learned shoemaking, and followed a vegetari- an diet. With the exception of his youngest daughter, Alexandra, Tolstoy's family re- mained hostile to his teaching. The breach be- tween him and his wife grew steadily wider. In 1879 he wrote the Kreutzer Sonata in which he attacked the normal state of marriage and extolled a life of celibacy and chastity. In 1881 he divided his estate among his heirs and, a few years later, despite the opposition of his wife, announced that he would forego royal- ties on all the works published after his con- version. Tolstoy made no attempt at first to propa- gate his religious teaching, although it attracted many followers. After a visit to the Moscow slums iri 1881, he became concerned with social conditions, and he subsequently aided the suf- ferers of the famine by sponsoring two hun- dred and fifty relief kitchens. After his meet- ing and intimacy with Chertkov, "Tolstoyism" began to develop as an organized sect. Tol- stoy's writings became almost exclusively pre- occupied with religious problems. In addition to numerous pamphlets and plays, he wrote IV hat is Art? (1896), in which he explained his new aesthetic theories, and Hadji-Murad, (1904), which became the favorite work of his old age. Although his activities were looked upon with increasing suspicion by the official authorities, Tolstoy escaped official censure until 1901, when he was excommunicated by the Orthodox Church. His followers were f re- quently subjected to persecution, and many were either banished or imprisoned. Tolstoy's last years were embittered by mounting hostility within his own household. Although his personal life was ascetic, he felt the ambiguity of his position as a preacher of poverty living on his great estate. Finally, at the age of eighty-two, with the aid of his daugh- ter, Alexandra, he fled from home. His health broke down a few days later, and he was re- moved from the train to the station-master's hut at Astopovo, where he died, November 7, 1910. He was buried at Yasnaya Polyana, in the first public funeral to be held in Russia without religious rites. " 
] 
} 
] 
} 
-highlighting: { 
-mateva_highlight: { 
-largetext_en: [ 
"COUNT LEO NIKOLAYEVICH TOLSTOY was born August 28, 1828, at the family estate of Yasna- ya <em>Polyana</em>, in the province of Tula. His moth- er died when he was three and his father six years later. Placed in the care of his aunts, he passed many of his early years at Kazan, where, in 1844, after a preliminary training by French tutors, he entered the university. He cared lit" 
" and study the educational and munici- pal systems of other countries. That year, and again in 1860, he traveled in Europe. At Yas- naya <em>Polyana</em> in 1861 he liberated his serfs and opened a school, established on the principle that "everything which savours of compulsion is harmful." He started a magazine to promote his notions on education and at the same time served as an official" 
" doctor. Their early married life at Yasnaya <em>Polyana</em> was tranquil. Family cares occupied the Countess, and in the course of her life she bore thirteen children, nine of whom survived infancy. Yet she also acted as a copyist for her husband, who after their marriage turned again to writ- ing. He was soon at work upon "a novel of the i8io's and *2o's" which absorbed all his time" 
" position as a preacher of poverty living on his great estate. Finally, at the age of eighty-two, with the aid of his daugh- ter, Alexandra, he fled from home. His health broke down a few days later, and he was re- moved from the train to the station-master's hut at Astopovo, where he died, November 7, 1910. He was buried at Yasnaya <em>Polyana</em>, in the first public funeral to be held" 
] 
} 
} 
} 
+0

你好@arun和偉大的感謝。我嘗試了你的查詢,只是改變了字段名(largetext_en),查詢詞和document_id。再一次,我得到了正確的文件,錯誤地突出顯示。 – Mateva 2013-03-01 11:55:49

+0

這可能是什麼:錯誤的編碼?我試圖強制所有東西都是UTF-8。它可能是我的文檔的大小?它包含大約200 000個字符。 – Mateva 2013-03-01 12:02:15

0

注意查詢有hl.maxAnalyzedCharacters=2147483647,但這是錯誤的參數名稱 - 發生了什麼,而不是想對你的努力hl.maxAnalyzedChars

相關問題