使用Solr DocumentExpressionDictionaryFactory的无效引用获取异常

时间:2016-10-14 06:53:57

标签: solr

我正在使用solr 6.2。我正在尝试在Solr搜索组件中配置多个建议器定义,并获得错误信息,如:

public sealed partial class MainPage : Page
{
    private bool _isScroll = false;
    private bool _isSlide = false;

    public MainPage()
    {
        this.InitializeComponent();
        var vm = new ViewModel();
        vm.ValueChanged += LetterSliderValueChanged;
        DataContext = vm;
    }

    /// <summary>
    /// Bring list items into view on the screen based on the value (letter) of the slider
    /// </summary>
    /// <param name="sender">The view model to bring into view</param>
    private void LetterSliderValueChanged(object sender, RoutedEventArgs e)
    {
        if (_isScroll) return;
        if (sender == null) return;

        _isSlide = true;

        ListView?.ScrollIntoView(sender, ScrollIntoViewAlignment.Leading);
    }


    /// <summary>
    /// Update the position of the slider when the ListView is scrolling from a normal touch
    /// </summary>
    private void ScrollViewerViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
    {
        if (_isSlide)
        {
            _isSlide = false;
            return;
        }

        _isScroll = true;

        var scrollViewer = sender as ScrollViewer;
        var scrollBars = scrollViewer.GetDescendantsOfType<ScrollBar>();
        var verticalBar = scrollBars.FirstOrDefault(x => x.Orientation == Orientation.Vertical);

        // Normalize the scales to move the slider thumb in sync with scrolling
        var sliderTotal = LetterSlider.Maximum - LetterSlider.Minimum;
        var barTotal = verticalBar.Maximum - verticalBar.Minimum;
        var barPercent = verticalBar.Value / barTotal;
        LetterSlider.Value = (barPercent * sliderTotal) + LetterSlider.Minimum;

        _isScroll = false;
    }

    /// <summary>
    /// Add the slider method to the ListView's ScrollViewer Viewchanged event
    /// </summary>
    private void ListViewLoaded(object sender, RoutedEventArgs e)
    {
        var listview = sender as ListView;
        if (listview == null) return;
        var scrollViewer = listview.GetFirstDescendantOfType<ScrollViewer>();
        scrollViewer.ViewChanged -= ScrollViewerViewChanged;
        scrollViewer.ViewChanged += ScrollViewerViewChanged;
    }
}

我的Solrconfig.xml中的配置是:

<Slider x:Name="LetterSlider" Orientation="Vertical"
            Value="{Binding SliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
            Maximum="{Binding MaxSliderLetter, Mode=OneTime}" 
            Minimum="{Binding MinSliderLetter, Mode=OneTime}" 
            RenderTransformOrigin="0.5,0.5">
        <Slider.RenderTransform>
            <RotateTransform Angle="180"/>
        </Slider.RenderTransform>
</Slider>

    //Method to update the ListView to show items based on the letter of the slider
    public RoutedEventHandler ValueChanged;

    public int SliderValue
    {
        get { return _sliderValue; }
        set
        {
            _sliderValue = value;
            NotifyPropertyChanged("SliderValue");

            char letter = (char)_sliderValue;
            var items = ItemsGroup.FirstOrDefault(i => (char)i.Key == letter);
            if (items == null) return;
            ValueChanged(items.FirstOrDefault(), new RoutedEventArgs());
        }
    }

从lucene的来源我知道字段java.lang.IllegalArgumentException: Invalid reference 'softId_suggest' at org.apache.lucene.expressions.SimpleBindings.getValueSource(SimpleBindings.java:84) at org.apache.lucene.expressions.ExpressionValueSource.<init>(ExpressionValueSource.java:45) at org.apache.lucene.expressions.Expression.getValueSource(Expression.java:80) at org.apache.solr.spelling.suggest.DocumentExpressionDictionaryFactory.fromExpression(DocumentExpressionDictionaryFactory.java:107) at org.apache.solr.spelling.suggest.DocumentExpressionDictionaryFactory.create(DocumentExpressionDictionaryFactory.java:92) at org.apache.solr.spelling.suggest.SolrSuggester.build(SolrSuggester.java:174) at org.apache.solr.handler.component.SuggestComponent$SuggesterListener.buildSuggesterIndex(SuggestComponent.java:528) at org.apache.solr.handler.component.SuggestComponent$SuggesterListener.newSearcher(SuggestComponent.java:508) at org.apache.solr.core.SolrCore.lambda$3(SolrCore.java:1863) at java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:229) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 似乎是空的,但是如何配置它是对的?

1 个答案:

答案 0 :(得分:1)

在您的说明中,您说您在 solrconfig.xml 中配置了softId_suggest。但是这些字段是在托管架构文件中配置的。所以,无论是问题还是你需要纠正这个问题。

如果定义正确,请确保已重新加载核心,重新运行导入并提交。

然后,我会检查Admin UI的Schema页面并确保该字段同时出现在下拉列表中并且已加载了一些值( Load Term Info 按钮)。