コード例 #1
0
        protected override Query[] PrepareQueries()
        {
            int    maxQueries = m_config.Get("query.file.maxQueries", 1000);
            Config srcConfig  = new Config(new Dictionary <string, string>());

            srcConfig.Set("docs.file", m_config.Get("query.file", null));
            srcConfig.Set("line.parser", m_config.Get("query.file.line.parser", null));
            srcConfig.Set("content.source.forever", "false");

            JCG.List <Query> queries = new JCG.List <Query>();
            LineDocSource    src     = new LineDocSource();

            try
            {
                src.SetConfig(srcConfig);
                src.ResetInputs();
                DocData docData = new DocData();
                for (int i = 0; i < maxQueries; i++)
                {
                    docData = src.GetNextDocData(docData);
                    IShape shape = SpatialDocMaker.MakeShapeFromString(m_strategy, docData.Name, docData.Body);
                    if (shape != null)
                    {
                        shape = m_shapeConverter.Convert(shape);
                        queries.Add(MakeQueryFromShape(shape));
                    }
                    else
                    {
                        i--;//skip
                    }
                }
            }
#pragma warning disable 168
            catch (NoMoreDataException e)
#pragma warning restore 168
            {
                //all-done
            }
            finally
            {
                src.Dispose();
            }
            return(queries.ToArray());
        }
コード例 #2
0
        // LUCENENET specific: de-nested IShapeConverter

        public override Document MakeDocument()
        {
            DocState docState = GetDocState();

            Document doc = base.MakeDocument();

            // Set SPATIAL_FIELD from body
            DocData docData = docState.docData;
            //   makeDocument() resets docState.getBody() so we can't look there; look in Document
            string shapeStr = doc.GetField(DocMaker.BODY_FIELD).GetStringValue();
            IShape shape    = MakeShapeFromString(strategy, docData.Name, shapeStr);

            if (shape != null)
            {
                shape = shapeConverter.Convert(shape);
                //index
                foreach (Field f in strategy.CreateIndexableFields(shape))
                {
                    doc.Add(f);
                }
            }

            return(doc);
        }